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" @@ -99,7 +99,7 @@ {"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": 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, 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, 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": 6, "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"}} @@ -129,7 +129,7 @@ {"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": 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 = [-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 = [-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 = [-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": 12, "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"}} @@ -315,13 +315,13 @@ {"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": 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 = [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": 1, "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": 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 = [[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": 18, "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"}} @@ -400,7 +400,7 @@ {"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": 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 = [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, 1, 2, 3, 4, 5, 6, 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, 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": 7, "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"}}