diff --git "a/data/train/javascript-003.jsonl" "b/data/train/javascript-003.jsonl" --- "a/data/train/javascript-003.jsonl" +++ "b/data/train/javascript-003.jsonl" @@ -1,4 +1,3 @@ -{"question_id": 2513, "task_id": "minimize-the-maximum-of-two-arrays", "difficulty": "Medium", "problem_description": "We have two arrays arr1 and arr2 which are initially empty. You need to add positive integers to them such that they satisfy all the following conditions:\n\n- arr1 contains uniqueCnt1 distinct positive integers, each of which is not divisible by divisor1.\n- arr2 contains uniqueCnt2 distinct positive integers, each of which is not divisible by divisor2.\n- No integer is present in both arr1 and arr2.\n\nGiven divisor1, divisor2, uniqueCnt1, and uniqueCnt2, return the minimum possible maximum integer that can be present in either array.\n\nExample 1:\n\nInput: divisor1 = 2, divisor2 = 7, uniqueCnt1 = 1, uniqueCnt2 = 3\nOutput: 4\nExplanation:\nWe can distribute the first 4 natural numbers into arr1 and arr2.\narr1 = [1] and arr2 = [2,3,4].\nWe can see that both arrays satisfy all the conditions.\nSince the maximum value is 4, we return it.\n\nExample 2:\n\nInput: divisor1 = 3, divisor2 = 5, uniqueCnt1 = 2, uniqueCnt2 = 1\nOutput: 3\nExplanation:\nHere arr1 = [1,2], and arr2 = [3] satisfy all conditions.\nSince the maximum value is 3, we return it.\n\nExample 3:\n\nInput: divisor1 = 2, divisor2 = 4, uniqueCnt1 = 8, uniqueCnt2 = 2\nOutput: 15\nExplanation:\nHere, the final possible arrays can be arr1 = [1,3,5,7,9,11,13,15], and arr2 = [2,6].\nIt can be shown that it is not possible to obtain a lower maximum satisfying all conditions.\n\nConstraints:\n\n- 2 <= divisor1, divisor2 <= 10^5\n- 1 <= uniqueCnt1, uniqueCnt2 < 10^9\n- 2 <= uniqueCnt1 + uniqueCnt2 <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(divisor1 = 2,divisor2 = 7,uniqueCnt1 = 1,uniqueCnt2 = 3) == 4\n assert candidate(divisor1 = 2,divisor2 = 4,uniqueCnt1 = 8,uniqueCnt2 = 2) == 15\n assert candidate(divisor1 = 100,divisor2 = 101,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 200019803\n assert candidate(divisor1 = 100,divisor2 = 200,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 201005025\n assert candidate(divisor1 = 5,divisor2 = 10,uniqueCnt1 = 5,uniqueCnt2 = 5) == 11\n assert candidate(divisor1 = 7,divisor2 = 11,uniqueCnt1 = 10,uniqueCnt2 = 10) == 20\n assert candidate(divisor1 = 7,divisor2 = 13,uniqueCnt1 = 10,uniqueCnt2 = 10) == 20\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 2,uniqueCnt2 = 1) == 3\n assert candidate(divisor1 = 10,divisor2 = 15,uniqueCnt1 = 5,uniqueCnt2 = 6) == 11\n assert candidate(divisor1 = 7,divisor2 = 11,uniqueCnt1 = 3,uniqueCnt2 = 7) == 10\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 100454545\n assert candidate(divisor1 = 89,divisor2 = 97,uniqueCnt1 = 60000000,uniqueCnt2 = 40000000) == 100011584\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 20,uniqueCnt2 = 25) == 45\n assert candidate(divisor1 = 23,divisor2 = 29,uniqueCnt1 = 50000000,uniqueCnt2 = 30000000) == 80120120\n assert candidate(divisor1 = 13,divisor2 = 19,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 200813008\n assert candidate(divisor1 = 2,divisor2 = 3,uniqueCnt1 = 999999999,uniqueCnt2 = 1) == 1999999997\n assert candidate(divisor1 = 100000,divisor2 = 10000,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 100001000\n assert candidate(divisor1 = 30,divisor2 = 42,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 100478468\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 10000000,uniqueCnt2 = 20000000) == 30136363\n assert candidate(divisor1 = 45,divisor2 = 18,uniqueCnt1 = 200000000,uniqueCnt2 = 300000000) == 505617977\n assert candidate(divisor1 = 5,divisor2 = 7,uniqueCnt1 = 1,uniqueCnt2 = 999999999) == 1166666665\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 250000000,uniqueCnt2 = 250000000) == 502272727\n assert candidate(divisor1 = 61,divisor2 = 71,uniqueCnt1 = 70000000,uniqueCnt2 = 30000000) == 100023094\n assert candidate(divisor1 = 12,divisor2 = 18,uniqueCnt1 = 1000,uniqueCnt2 = 1000) == 2057\n assert candidate(divisor1 = 2,divisor2 = 5,uniqueCnt1 = 500000000,uniqueCnt2 = 499999999) == 1111111109\n assert candidate(divisor1 = 4,divisor2 = 6,uniqueCnt1 = 5,uniqueCnt2 = 8) == 14\n assert candidate(divisor1 = 4,divisor2 = 6,uniqueCnt1 = 300000000,uniqueCnt2 = 200000000) == 545454545\n assert candidate(divisor1 = 10000,divisor2 = 20000,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 100005000\n assert candidate(divisor1 = 8,divisor2 = 12,uniqueCnt1 = 40000000,uniqueCnt2 = 60000000) == 104347826\n assert candidate(divisor1 = 99999,divisor2 = 99998,uniqueCnt1 = 100000,uniqueCnt2 = 100000) == 200000\n assert candidate(divisor1 = 50000,divisor2 = 100000,uniqueCnt1 = 10000000,uniqueCnt2 = 10000000) == 20000200\n assert candidate(divisor1 = 29,divisor2 = 41,uniqueCnt1 = 60000000,uniqueCnt2 = 40000000) == 100084175\n assert candidate(divisor1 = 15,divisor2 = 20,uniqueCnt1 = 75000000,uniqueCnt2 = 25000000) == 101694915\n assert candidate(divisor1 = 19,divisor2 = 23,uniqueCnt1 = 150000000,uniqueCnt2 = 150000000) == 300688073\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 107142857\n assert candidate(divisor1 = 50000,divisor2 = 75000,uniqueCnt1 = 60000000,uniqueCnt2 = 40000000) == 100000666\n assert candidate(divisor1 = 20,divisor2 = 30,uniqueCnt1 = 500000000,uniqueCnt2 = 400000000) == 915254237\n assert candidate(divisor1 = 6,divisor2 = 8,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 104347826\n assert candidate(divisor1 = 100000,divisor2 = 50000,uniqueCnt1 = 50000000,uniqueCnt2 = 40000000) == 90000900\n assert candidate(divisor1 = 10,divisor2 = 15,uniqueCnt1 = 75000000,uniqueCnt2 = 25000000) == 103448275\n assert candidate(divisor1 = 100000,divisor2 = 100000,uniqueCnt1 = 450000000,uniqueCnt2 = 450000000) == 900009000\n assert candidate(divisor1 = 23,divisor2 = 37,uniqueCnt1 = 50000000,uniqueCnt2 = 49999999) == 100117646\n assert candidate(divisor1 = 23,divisor2 = 37,uniqueCnt1 = 45000000,uniqueCnt2 = 55000000) == 100117647\n assert candidate(divisor1 = 11,divisor2 = 13,uniqueCnt1 = 100,uniqueCnt2 = 150) == 251\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 214285714\n assert candidate(divisor1 = 1000,divisor2 = 500,uniqueCnt1 = 40000000,uniqueCnt2 = 60000000) == 100100100\n assert candidate(divisor1 = 4,divisor2 = 6,uniqueCnt1 = 100000000,uniqueCnt2 = 99999999) == 218181817\n assert candidate(divisor1 = 5,divisor2 = 7,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 102941176\n assert candidate(divisor1 = 17,divisor2 = 31,uniqueCnt1 = 99999999,uniqueCnt2 = 1) == 106249998\n assert candidate(divisor1 = 99998,divisor2 = 99999,uniqueCnt1 = 100000,uniqueCnt2 = 100000) == 200000\n assert candidate(divisor1 = 10,divisor2 = 15,uniqueCnt1 = 100000000,uniqueCnt2 = 1) == 111111111\n assert candidate(divisor1 = 4,divisor2 = 6,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 218181818\n assert candidate(divisor1 = 6,divisor2 = 8,uniqueCnt1 = 75000000,uniqueCnt2 = 25000000) == 104347826\n assert candidate(divisor1 = 77,divisor2 = 42,uniqueCnt1 = 500,uniqueCnt2 = 500) == 1002\n assert candidate(divisor1 = 11,divisor2 = 13,uniqueCnt1 = 20000000,uniqueCnt2 = 15000000) == 35246478\n assert candidate(divisor1 = 7,divisor2 = 14,uniqueCnt1 = 25000000,uniqueCnt2 = 25000000) == 53846153\n assert candidate(divisor1 = 15,divisor2 = 25,uniqueCnt1 = 80000000,uniqueCnt2 = 70000000) == 152027027\n assert candidate(divisor1 = 11,divisor2 = 13,uniqueCnt1 = 99999999,uniqueCnt2 = 99999999) == 201408448\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 100,uniqueCnt2 = 200) == 321\n assert candidate(divisor1 = 25,divisor2 = 40,uniqueCnt1 = 100,uniqueCnt2 = 150) == 251\n assert candidate(divisor1 = 6,divisor2 = 9,uniqueCnt1 = 15,uniqueCnt2 = 20) == 37\n assert candidate(divisor1 = 6,divisor2 = 9,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 105882352\n assert candidate(divisor1 = 23,divisor2 = 31,uniqueCnt1 = 200000000,uniqueCnt2 = 300000000) == 500702247\n assert candidate(divisor1 = 5,divisor2 = 6,uniqueCnt1 = 1000000,uniqueCnt2 = 500000) == 1551724\n assert candidate(divisor1 = 67,divisor2 = 89,uniqueCnt1 = 400000000,uniqueCnt2 = 400000000) == 800134183\n assert candidate(divisor1 = 11,divisor2 = 13,uniqueCnt1 = 200000000,uniqueCnt2 = 1) == 219999999\n assert candidate(divisor1 = 37,divisor2 = 41,uniqueCnt1 = 9876543,uniqueCnt2 = 1234567) == 11118439\n assert candidate(divisor1 = 7,divisor2 = 13,uniqueCnt1 = 300000000,uniqueCnt2 = 300000000) == 606666666\n assert candidate(divisor1 = 5,divisor2 = 7,uniqueCnt1 = 99999999,uniqueCnt2 = 1) == 124999998\n assert candidate(divisor1 = 97,divisor2 = 101,uniqueCnt1 = 1000000,uniqueCnt2 = 500000) == 1500153\n assert candidate(divisor1 = 10000,divisor2 = 100000,uniqueCnt1 = 90000000,uniqueCnt2 = 10000000) == 100001000\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 5,uniqueCnt2 = 10) == 15\n assert candidate(divisor1 = 10,divisor2 = 15,uniqueCnt1 = 100000000,uniqueCnt2 = 200000000) == 310344827\n assert candidate(divisor1 = 77,divisor2 = 42,uniqueCnt1 = 33000000,uniqueCnt2 = 66000000) == 99214750\n assert candidate(divisor1 = 6,divisor2 = 8,uniqueCnt1 = 99999999,uniqueCnt2 = 1) == 119999998\n assert candidate(divisor1 = 5,divisor2 = 10,uniqueCnt1 = 50,uniqueCnt2 = 50) == 111\n assert candidate(divisor1 = 101,divisor2 = 103,uniqueCnt1 = 1000000,uniqueCnt2 = 1000000) == 2000192\n assert candidate(divisor1 = 23,divisor2 = 31,uniqueCnt1 = 50000000,uniqueCnt2 = 30000000) == 80112359\n assert candidate(divisor1 = 11,divisor2 = 22,uniqueCnt1 = 100000000,uniqueCnt2 = 1) == 109999999\n assert candidate(divisor1 = 11,divisor2 = 22,uniqueCnt1 = 300000000,uniqueCnt2 = 300000000) == 628571428\n assert candidate(divisor1 = 23,divisor2 = 29,uniqueCnt1 = 100000,uniqueCnt2 = 100000) == 200300\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 100000000,uniqueCnt2 = 50000000) == 160714285\n assert candidate(divisor1 = 5,divisor2 = 3,uniqueCnt1 = 100,uniqueCnt2 = 150) == 267\n assert candidate(divisor1 = 7,divisor2 = 11,uniqueCnt1 = 10000000,uniqueCnt2 = 10000000) == 20263157\n assert candidate(divisor1 = 4,divisor2 = 6,uniqueCnt1 = 250000000,uniqueCnt2 = 250000000) == 545454545\n assert candidate(divisor1 = 8,divisor2 = 9,uniqueCnt1 = 2000000,uniqueCnt2 = 3000000) == 5070422\n assert candidate(divisor1 = 100000,divisor2 = 99999,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 200000000\n assert candidate(divisor1 = 10,divisor2 = 25,uniqueCnt1 = 50000000,uniqueCnt2 = 100000000) == 153061224\n assert candidate(divisor1 = 5,divisor2 = 15,uniqueCnt1 = 100000000,uniqueCnt2 = 50000000) == 160714285\n assert candidate(divisor1 = 5,divisor2 = 10,uniqueCnt1 = 50000000,uniqueCnt2 = 49999999) == 111111109\n assert candidate(divisor1 = 2,divisor2 = 3,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 239999999\n assert candidate(divisor1 = 2,divisor2 = 4,uniqueCnt1 = 99999999,uniqueCnt2 = 1) == 199999997\n assert candidate(divisor1 = 17,divisor2 = 29,uniqueCnt1 = 150000000,uniqueCnt2 = 150000000) == 300609756\n assert candidate(divisor1 = 9,divisor2 = 12,uniqueCnt1 = 250000000,uniqueCnt2 = 250000000) == 514285714\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 300000000,uniqueCnt2 = 200000000) == 502272727\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 500000000,uniqueCnt2 = 400000000) == 964285714\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 200909090\n assert candidate(divisor1 = 71,divisor2 = 73,uniqueCnt1 = 10000000,uniqueCnt2 = 10000000) == 20003859\n assert candidate(divisor1 = 99,divisor2 = 101,uniqueCnt1 = 200000000,uniqueCnt2 = 300000000) == 500050010\n assert candidate(divisor1 = 3,divisor2 = 6,uniqueCnt1 = 100,uniqueCnt2 = 200) == 359\n assert candidate(divisor1 = 10,divisor2 = 15,uniqueCnt1 = 80000000,uniqueCnt2 = 20000000) == 103448275\n", "comparison": "exact"}, "public_tests": ["2\n7\n1\n3", "3\n5\n2\n1", "2\n4\n8\n2"], "hints": ["Use binary search to find smallest maximum element.", "Add numbers divisible by x in nums2 and vice versa."], "metadata": {"canonical_parameter_names": ["divisor1", "divisor2", "uniqueCnt1", "uniqueCnt2"], "leetcode_dataset_entry_point": "Solution().minimizeSet", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:32+00:00", "tests_total": 108, "tests_dropped": 7, "flags": [], "topic_tags": ["math", "binary-search", "number-theory", "least-common-multiple", "inclusion-exclusion-principle"]}, "language": "javascript", "interface": {"raw_signature": "var minimizeSet = function(divisor1, divisor2, uniqueCnt1, uniqueCnt2) {", "container": null, "callable": "minimizeSet", "parameters": [{"name": "divisor1", "type": "number"}, {"name": "divisor2", "type": "number"}, {"name": "uniqueCnt1", "type": "number"}, {"name": "uniqueCnt2", "type": "number"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2515, "task_id": "shortest-distance-to-target-string-in-a-circular-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed circular string array words and a string target. A circular array means that the array's end connects to the array's beginning.\n\n- Formally, the next element of words[i] is words[(i + 1) % n] and the previous element of words[i] is words[(i - 1 + n) % n], where n is the length of words.\n\nStarting from startIndex, you can move to either the next word or the previous word with 1 step at a time.\n\nReturn the shortest distance needed to reach the string target. If the string target does not exist in words, return -1.\n\nExample 1:\n\nInput: words = [\"hello\",\"i\",\"am\",\"leetcode\",\"hello\"], target = \"hello\", startIndex = 1\nOutput: 1\nExplanation: We start from index 1 and can reach \"hello\" by\n- moving 3 units to the right to reach index 4.\n- moving 2 units to the left to reach index 4.\n- moving 4 units to the right to reach index 0.\n- moving 1 unit to the left to reach index 0.\nThe shortest distance to reach \"hello\" is 1.\n\nExample 2:\n\nInput: words = [\"a\",\"b\",\"leetcode\"], target = \"leetcode\", startIndex = 0\nOutput: 1\nExplanation: We start from index 0 and can reach \"leetcode\" by\n- moving 2 units to the right to reach index 2.\n- moving 1 unit to the left to reach index 2.\nThe shortest distance to reach \"leetcode\" is 1.\n\nExample 3:\n\nInput: words = [\"i\",\"eat\",\"leetcode\"], target = \"ate\", startIndex = 0\nOutput: -1\nExplanation: Since \"ate\" does not exist in words, we return -1.\n\nConstraints:\n\n- 1 <= words.length <= 100\n- 1 <= words[i].length <= 100\n- words[i] and target consist of only lowercase English letters.\n- 0 <= startIndex < words.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['abc', 'def', 'ghi'],target = \"xyz\",startIndex = 1) == -1\n assert candidate(words = ['apple', 'banana', 'cherry', 'date'],target = \"banana\",startIndex = 2) == 1\n assert candidate(words = ['cat', 'dog', 'bird', 'fish'],target = \"cat\",startIndex = 3) == 1\n assert candidate(words = ['dog', 'cat', 'bat'],target = \"dog\",startIndex = 2) == 1\n assert candidate(words = ['hello', 'i', 'am', 'leetcode', 'hello'],target = \"hello\",startIndex = 1) == 1\n assert candidate(words = ['a', 'a', 'a', 'a'],target = \"a\",startIndex = 0) == 0\n assert candidate(words = ['a', 'b', 'c', 'd'],target = \"a\",startIndex = 3) == 1\n assert candidate(words = ['a', 'b', 'leetcode'],target = \"leetcode\",startIndex = 0) == 1\n assert candidate(words = ['dog', 'cat', 'bat'],target = \"rat\",startIndex = 1) == -1\n assert candidate(words = ['one', 'two', 'three', 'four'],target = \"one\",startIndex = 3) == 1\n assert candidate(words = ['red', 'blue', 'green'],target = \"yellow\",startIndex = 1) == -1\n assert candidate(words = ['i', 'eat', 'leetcode'],target = \"ate\",startIndex = 0) == -1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"five\",startIndex = 3) == 1\n assert candidate(words = ['apple', 'banana', 'cherry'],target = \"banana\",startIndex = 2) == 1\n assert candidate(words = ['z', 'y', 'x', 'w', 'v'],target = \"v\",startIndex = 4) == 0\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"five\",startIndex = 0) == 1\n assert candidate(words = ['red', 'blue', 'green'],target = \"green\",startIndex = 1) == 1\n assert candidate(words = ['abc', 'def', 'ghi'],target = \"def\",startIndex = 1) == 0\n assert candidate(words = ['red', 'blue', 'green'],target = \"blue\",startIndex = 1) == 0\n assert candidate(words = ['a', 'a', 'a', 'a'],target = \"b\",startIndex = 0) == -1\n assert candidate(words = ['a', 'a', 'a', 'a', 'a'],target = \"a\",startIndex = 2) == 0\n assert candidate(words = ['dog', 'cat', 'bird'],target = \"fish\",startIndex = 1) == -1\n assert candidate(words = ['sun', 'moon', 'star'],target = \"planet\",startIndex = 1) == -1\n assert candidate(words = ['a', 'b', 'c', 'd'],target = \"d\",startIndex = 2) == 1\n assert candidate(words = ['a', 'b', 'c', 'd'],target = \"b\",startIndex = 2) == 1\n assert candidate(words = ['rotate', 'me', 'around', 'and', 'around', 'again', 'rotate'],target = \"around\",startIndex = 0) == 2\n assert candidate(words = ['x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g'],target = \"d\",startIndex = 0) == 4\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"five\",startIndex = 0) == 4\n assert candidate(words = ['zebra', 'yak', 'xylophone', 'wolf', 'vulture'],target = \"wolf\",startIndex = 1) == 2\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],target = \"mno\",startIndex = 0) == 4\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],target = \"e\",startIndex = 8) == 4\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'comet', 'asteroid', 'galaxy'],target = \"galaxy\",startIndex = 3) == 3\n assert candidate(words = ['same', 'words', 'here', 'are', 'same', 'words'],target = \"words\",startIndex = 2) == 1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"seven\",startIndex = 4) == 2\n assert candidate(words = ['hello', 'world', 'hello', 'world', 'hello', 'world'],target = \"hello\",startIndex = 4) == 0\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape'],target = \"date\",startIndex = 0) == 3\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],target = \"mno\",startIndex = 6) == 2\n assert candidate(words = ['repeat', 'this', 'sentence', 'repeat', 'this', 'sentence'],target = \"sentence\",startIndex = 3) == 1\n assert candidate(words = ['search', 'for', 'this', 'word', 'in', 'this', 'circular', 'array'],target = \"this\",startIndex = 4) == 1\n assert candidate(words = ['single'],target = \"single\",startIndex = 0) == 0\n assert candidate(words = ['car', 'bus', 'bike', 'train', 'truck', 'van'],target = \"van\",startIndex = 3) == 2\n assert candidate(words = ['red', 'blue', 'green', 'yellow', 'red', 'blue', 'green', 'yellow'],target = \"yellow\",startIndex = 2) == 1\n assert candidate(words = ['unique', 'words', 'only', 'here'],target = \"only\",startIndex = 1) == 1\n assert candidate(words = ['red', 'blue', 'green', 'yellow', 'orange', 'purple', 'pink'],target = \"purple\",startIndex = 1) == 3\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"one\",startIndex = 9) == 1\n assert candidate(words = ['water', 'fire', 'earth', 'air', 'ice', 'steam', 'cloud'],target = \"cloud\",startIndex = 3) == 3\n assert candidate(words = ['hello', 'world', 'python', 'code', 'challenge'],target = \"python\",startIndex = 3) == 1\n assert candidate(words = ['algorithm', 'data', 'structures', 'algorithm', 'data'],target = \"structures\",startIndex = 0) == 2\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"five\",startIndex = 8) == 4\n assert candidate(words = ['python', 'java', 'c', 'cpp', 'ruby', 'swift', 'go'],target = \"cpp\",startIndex = 5) == 2\n assert candidate(words = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],target = \"y\",startIndex = 5) == 1\n assert candidate(words = ['dog', 'cat', 'mouse', 'rat', 'elephant', 'giraffe', 'hippo'],target = \"elephant\",startIndex = 2) == 2\n assert candidate(words = ['orange', 'peach', 'plum', 'grape', 'kiwi'],target = \"peach\",startIndex = 3) == 2\n assert candidate(words = ['last', 'element', 'is', 'the', 'target'],target = \"target\",startIndex = 3) == 1\n assert candidate(words = ['cat', 'dog', 'fish', 'bird', 'elephant', 'antelope', 'hippo'],target = \"hippo\",startIndex = 2) == 3\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],target = \"vwx\",startIndex = 4) == 3\n assert candidate(words = ['loop', 'around', 'this', 'circular', 'array'],target = \"array\",startIndex = 1) == 2\n assert candidate(words = ['circular', 'array', 'test', 'case', 'example', 'circular'],target = \"example\",startIndex = 4) == 0\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't'],target = \"p\",startIndex = 15) == 0\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"seven\",startIndex = 7) == 1\n assert candidate(words = ['a', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog'],target = \"lazy\",startIndex = 3) == 4\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa'],target = \"aaaaaa\",startIndex = 1) == 4\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"ten\",startIndex = 2) == 3\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'galaxy', 'universe', 'comet'],target = \"moon\",startIndex = 4) == 3\n assert candidate(words = ['hello', 'world', 'python', 'programming', 'hello', 'world'],target = \"programming\",startIndex = 4) == 1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"two\",startIndex = 8) == 3\n assert candidate(words = ['hello', 'world', 'python', 'programming', 'is', 'fun'],target = \"programming\",startIndex = 2) == 1\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'galaxy', 'universe', 'sun', 'moon'],target = \"galaxy\",startIndex = 6) == 2\n assert candidate(words = ['red', 'blue', 'green', 'yellow', 'purple', 'orange', 'pink'],target = \"pink\",startIndex = 6) == 0\n assert candidate(words = ['hello', 'world', 'python', 'programming', 'hello'],target = \"programming\",startIndex = 2) == 1\n assert candidate(words = ['mango', 'banana', 'mango', 'banana', 'mango'],target = \"banana\",startIndex = 0) == 1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"four\",startIndex = 7) == 4\n assert candidate(words = ['hello', 'world', 'this', 'is', 'a', 'circular', 'array'],target = \"is\",startIndex = 5) == 2\n assert candidate(words = ['ocean', 'lake', 'river', 'pond', 'creek', 'stream', 'flood', 'bay', 'harbor', 'gulf'],target = \"stream\",startIndex = 5) == 0\n assert candidate(words = ['dog', 'cat', 'bird', 'fish', 'dog', 'cat', 'bird', 'fish'],target = \"fish\",startIndex = 7) == 0\n assert candidate(words = ['banana', 'apple', 'orange', 'grape', 'banana', 'apple', 'orange', 'grape'],target = \"orange\",startIndex = 5) == 1\n assert candidate(words = ['longwordthatwillnotmatch', 'anotherlongword', 'yetanotherlongword', 'stillanotherlongword'],target = \"nonexistent\",startIndex = 1) == -1\n assert candidate(words = ['algorithm', 'data', 'structure', 'algorithm', 'data', 'structure'],target = \"structure\",startIndex = 2) == 0\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven'],target = \"four\",startIndex = 6) == 3\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'galaxy'],target = \"galaxy\",startIndex = 2) == 2\n assert candidate(words = ['red', 'blue', 'green', 'yellow', 'purple', 'orange'],target = \"blue\",startIndex = 5) == 2\n assert candidate(words = ['x', 'y', 'z', 'a', 'b', 'c', 'd', 'e'],target = \"d\",startIndex = 7) == 1\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa'],target = \"delta\",startIndex = 8) == 5\n assert candidate(words = ['x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g'],target = \"d\",startIndex = 9) == 3\n assert candidate(words = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],target = \"y\",startIndex = 4) == 0\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape'],target = \"date\",startIndex = 5) == 2\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape'],target = \"banana\",startIndex = 6) == 2\n assert candidate(words = ['find', 'the', 'shortest', 'distance', 'in', 'a', 'circular', 'array'],target = \"distance\",startIndex = 5) == 2\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape'],target = \"banana\",startIndex = 5) == 3\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],target = \"mno\",startIndex = 5) == 1\n assert candidate(words = ['hello', 'world', 'python', 'programming', 'code', 'hello'],target = \"code\",startIndex = 3) == 1\n assert candidate(words = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault', 'garply', 'waldo', 'fred', 'plugh', 'xyzzy', 'thud'],target = \"garply\",startIndex = 10) == 3\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape'],target = \"banana\",startIndex = 4) == 3\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],target = \"mno\",startIndex = 7) == 3\n assert candidate(words = ['aardvark', 'anteater', 'armadillo', 'baboon', 'badger', 'bat', 'bear', 'beaver', 'bison', 'boar'],target = \"badger\",startIndex = 9) == 5\n assert candidate(words = ['cat', 'dog', 'fish', 'bird', 'ant'],target = \"ant\",startIndex = 2) == 2\n assert candidate(words = ['repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat'],target = \"repeat\",startIndex = 5) == 0\n assert candidate(words = ['red', 'green', 'blue', 'yellow', 'orange', 'purple'],target = \"green\",startIndex = 5) == 2\n assert candidate(words = ['algorithm', 'data', 'structures', 'algorithm', 'data', 'structures'],target = \"data\",startIndex = 3) == 1\n assert candidate(words = ['x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w'],target = \"m\",startIndex = 10) == 5\n assert candidate(words = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj'],target = \"jjj\",startIndex = 9) == 0\n assert candidate(words = ['longerword', 'stringexample', 'anotherexample', 'yetanother', 'finalword'],target = \"anotherexample\",startIndex = 1) == 1\n assert candidate(words = ['complex', 'circular', 'array', 'problem', 'solution'],target = \"complex\",startIndex = 3) == 2\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],target = \"vwx\",startIndex = 8) == 1\n assert candidate(words = ['loop', 'circle', 'ring', 'cycle', 'wheel', 'orbit', 'oval'],target = \"oval\",startIndex = 3) == 3\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape'],target = \"grape\",startIndex = 1) == 2\n assert candidate(words = ['repeated', 'words', 'are', 'repeated', 'here', 'repeated'],target = \"repeated\",startIndex = 2) == 1\n assert candidate(words = ['hello', 'world', 'hello', 'python', 'world'],target = \"python\",startIndex = 2) == 1\n assert candidate(words = ['leetcode', 'problem', 'solving', 'leetcode', 'problem'],target = \"solving\",startIndex = 4) == 2\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],target = \"z\",startIndex = 0) == 1\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'galaxy', 'universe'],target = \"planet\",startIndex = 0) == 3\n assert candidate(words = ['zebra', 'yak', 'xylophone', 'wolf', 'unicorn', 'tiger', 'snake'],target = \"yak\",startIndex = 6) == 2\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],target = \"seven\",startIndex = 1) == 5\n assert candidate(words = ['cat', 'dog', 'fish', 'bird', 'elephant', 'tiger', 'lion', 'bear'],target = \"fish\",startIndex = 6) == 4\n assert candidate(words = ['circular', 'array', 'example', 'circular'],target = \"example\",startIndex = 2) == 0\n assert candidate(words = ['hello', 'world', 'leetcode', 'python', 'hello'],target = \"python\",startIndex = 0) == 2\n assert candidate(words = ['car', 'bike', 'truck', 'motorcycle', 'bus', 'train', 'boat', 'plane'],target = \"plane\",startIndex = 6) == 1\n assert candidate(words = ['unique', 'words', 'here', 'only', 'once'],target = \"once\",startIndex = 2) == 2\n assert candidate(words = ['coding', 'is', 'fun', 'coding', 'is', 'great'],target = \"great\",startIndex = 3) == 2\n assert candidate(words = ['find', 'me', 'if', 'you', 'can'],target = \"can\",startIndex = 3) == 1\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],target = \"vwx\",startIndex = 5) == 2\n assert candidate(words = ['abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij'],target = \"abcdefghij\",startIndex = 5) == 1\n assert candidate(words = ['repeat', 'this', 'is', 'a', 'test', 'repeat'],target = \"test\",startIndex = 4) == 0\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],target = \"planet\",startIndex = 0) == 1\n assert candidate(words = ['sun', 'moon', 'star'],target = \"planet\",startIndex = 0) == -1\n assert candidate(words = ['sun', 'moon', 'star', 'sky'],target = \"star\",startIndex = 3) == 1\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],target = \"planet\",startIndex = 2) == 1\n assert candidate(words = ['find', 'me', 'in', 'the', 'list'],target = \"list\",startIndex = 0) == 1\n assert candidate(words = ['flower', 'grass', 'tree', 'bush'],target = \"bush\",startIndex = 2) == 1\n assert candidate(words = ['xyz', 'uvw', 'rst', 'qpo'],target = \"rst\",startIndex = 3) == 1\n assert candidate(words = ['unique', 'words', 'here'],target = \"words\",startIndex = 1) == 0\n assert candidate(words = ['aaa', 'bbb', 'ccc'],target = \"aaa\",startIndex = 1) == 1\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl'],target = \"def\",startIndex = 3) == 2\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"two\",startIndex = 4) == 2\n assert candidate(words = ['up', 'down', 'left', 'right'],target = \"up\",startIndex = 1) == 1\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta', 'epsilon'],target = \"beta\",startIndex = 3) == 2\n assert candidate(words = ['dog', 'cat', 'mouse'],target = \"elephant\",startIndex = 1) == -1\n assert candidate(words = ['foo', 'bar', 'baz'],target = \"foo\",startIndex = 1) == 1\n assert candidate(words = ['dog', 'cat', 'bat'],target = \"mouse\",startIndex = 1) == -1\n assert candidate(words = ['sun', 'moon', 'star', 'sky'],target = \"moon\",startIndex = 3) == 2\n assert candidate(words = ['coding', 'is', 'fun', 'coding'],target = \"fun\",startIndex = 1) == 1\n assert candidate(words = ['zebra', 'giraffe', 'elephant'],target = \"hippo\",startIndex = 1) == -1\n assert candidate(words = ['red', 'blue', 'green', 'red'],target = \"red\",startIndex = 3) == 0\n assert candidate(words = ['one', 'two', 'three', 'four'],target = \"three\",startIndex = 0) == 2\n assert candidate(words = ['cat', 'dog', 'bird'],target = \"dog\",startIndex = 2) == 1\n assert candidate(words = ['cup', 'bottle', 'spoon', 'knife', 'cup'],target = \"spoon\",startIndex = 4) == 2\n assert candidate(words = ['dog', 'cat', 'bird', 'fish'],target = \"elephant\",startIndex = 1) == -1\n assert candidate(words = ['unique'],target = \"unique\",startIndex = 0) == 0\n assert candidate(words = ['hello', 'world', 'hello'],target = \"world\",startIndex = 2) == 1\n assert candidate(words = ['car', 'bike', 'bus', 'train', 'boat'],target = \"plane\",startIndex = 1) == -1\n assert candidate(words = ['red', 'green', 'blue', 'yellow'],target = \"blue\",startIndex = 1) == 1\n assert candidate(words = ['red', 'blue', 'green', 'yellow'],target = \"blue\",startIndex = 0) == 1\n assert candidate(words = ['one', 'two', 'three'],target = \"four\",startIndex = 1) == -1\n assert candidate(words = ['red', 'blue', 'green', 'yellow'],target = \"blue\",startIndex = 2) == 1\n assert candidate(words = ['xyz', 'uvw', 'rst', 'qpo'],target = \"qpo\",startIndex = 3) == 0\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],target = \"planet\",startIndex = 1) == 2\n assert candidate(words = ['fast', 'slow', 'quick'],target = \"quick\",startIndex = 1) == 1\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl'],target = \"abc\",startIndex = 3) == 1\n assert candidate(words = ['start', 'middle', 'end'],target = \"end\",startIndex = 0) == 1\n assert candidate(words = ['sun', 'moon', 'star'],target = \"planet\",startIndex = 2) == -1\n assert candidate(words = ['loop', 'start', 'end', 'loop'],target = \"loop\",startIndex = 2) == 1\n assert candidate(words = ['red', 'blue', 'green', 'yellow', 'purple'],target = \"green\",startIndex = 4) == 2\n assert candidate(words = ['car', 'bus', 'train', 'plane'],target = \"train\",startIndex = 3) == 1\n assert candidate(words = ['red', 'green', 'blue', 'yellow', 'black'],target = \"red\",startIndex = 4) == 1\n assert candidate(words = ['house', 'car', 'tree', 'road', 'house'],target = \"road\",startIndex = 0) == 2\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"six\",startIndex = 0) == -1\n assert candidate(words = ['zebra', 'giraffe', 'elephant', 'lion'],target = \"elephant\",startIndex = 1) == 1\n assert candidate(words = ['one', 'two', 'three', 'four'],target = \"three\",startIndex = 3) == 1\n assert candidate(words = ['car', 'bus', 'train'],target = \"train\",startIndex = 2) == 0\n assert candidate(words = ['one', 'two', 'three', 'four'],target = \"one\",startIndex = 2) == 2\n assert candidate(words = ['car', 'bike', 'train', 'bus'],target = \"bike\",startIndex = 3) == 2\n assert candidate(words = ['sun', 'moon', 'star'],target = \"star\",startIndex = 1) == 1\n assert candidate(words = ['search', 'this', 'array', 'for', 'target'],target = \"target\",startIndex = 2) == 2\n assert candidate(words = ['foo', 'bar', 'baz'],target = \"foo\",startIndex = 2) == 1\n assert candidate(words = ['a', 'b', 'c', 'd', 'e'],target = \"a\",startIndex = 4) == 1\n assert candidate(words = ['start', 'middle', 'end'],target = \"start\",startIndex = 2) == 1\n assert candidate(words = ['house', 'building', 'apartment'],target = \"house\",startIndex = 1) == 1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"one\",startIndex = 3) == 2\n assert candidate(words = ['up', 'down', 'left', 'right'],target = \"left\",startIndex = 3) == 1\n assert candidate(words = ['dog', 'cat', 'bird', 'fish'],target = \"dog\",startIndex = 3) == 1\n assert candidate(words = ['dog', 'cat', 'bat', 'rat'],target = \"rat\",startIndex = 3) == 0\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"three\",startIndex = 3) == 1\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl'],target = \"def\",startIndex = 2) == 1\n assert candidate(words = ['dog', 'cat', 'bird', 'fish'],target = \"fish\",startIndex = 3) == 0\n assert candidate(words = ['hello', 'world', 'hello'],target = \"world\",startIndex = 0) == 1\n assert candidate(words = ['coding', 'is', 'fun'],target = \"fun\",startIndex = 2) == 0\n assert candidate(words = ['one', 'two', 'three', 'four'],target = \"five\",startIndex = 2) == -1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six'],target = \"three\",startIndex = 0) == 2\n assert candidate(words = ['one', 'two', 'three', 'four'],target = \"four\",startIndex = 0) == 1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"one\",startIndex = 2) == 2\n assert candidate(words = ['dog', 'cat', 'bat', 'rat'],target = \"bat\",startIndex = 3) == 1\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],target = \"moon\",startIndex = 0) == 1\n assert candidate(words = ['repeat', 'repeat', 'repeat', 'repeat'],target = \"repeat\",startIndex = 2) == 0\n assert candidate(words = ['unique', 'words', 'only', 'here'],target = \"only\",startIndex = 0) == 2\n assert candidate(words = ['dog', 'cat', 'bat'],target = \"bat\",startIndex = 1) == 1\n assert candidate(words = ['sun', 'moon', 'star', 'sky'],target = \"moon\",startIndex = 0) == 1\n assert candidate(words = ['cat', 'dog', 'bird', 'fish'],target = \"dog\",startIndex = 2) == 1\n assert candidate(words = ['sun', 'moon', 'star'],target = \"moon\",startIndex = 2) == 1\n assert candidate(words = ['red', 'blue', 'green', 'yellow'],target = \"green\",startIndex = 0) == 2\n assert candidate(words = ['apple', 'banana', 'cherry', 'date'],target = \"banana\",startIndex = 3) == 2\n assert candidate(words = ['car', 'bike', 'train'],target = \"bus\",startIndex = 1) == -1\n assert candidate(words = ['sun', 'moon', 'star', 'planet', 'galaxy'],target = \"star\",startIndex = 3) == 1\n assert candidate(words = ['red', 'blue', 'green', 'red'],target = \"blue\",startIndex = 2) == 1\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry'],target = \"banana\",startIndex = 3) == 2\n assert candidate(words = ['one', 'two', 'three', 'four'],target = \"five\",startIndex = 0) == -1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"three\",startIndex = 0) == 2\n assert candidate(words = ['apple', 'banana', 'cherry', 'date', 'elderberry'],target = \"banana\",startIndex = 2) == 1\n assert candidate(words = ['test', 'case', 'test'],target = \"test\",startIndex = 2) == 0\n assert candidate(words = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge'],target = \"qux\",startIndex = 5) == 2\n assert candidate(words = ['hello', 'hello', 'hello'],target = \"hello\",startIndex = 1) == 0\n assert candidate(words = ['a', 'a', 'a', 'a'],target = \"a\",startIndex = 2) == 0\n assert candidate(words = ['red', 'blue', 'green'],target = \"blue\",startIndex = 0) == 1\n assert candidate(words = ['left', 'right', 'up', 'down'],target = \"up\",startIndex = 1) == 1\n assert candidate(words = ['zebra', 'yak', 'antelope'],target = \"antelope\",startIndex = 1) == 1\n assert candidate(words = ['a', 'b', 'c', 'd', 'e'],target = \"d\",startIndex = 2) == 1\n assert candidate(words = ['cat', 'dog', 'elephant', 'cat'],target = \"elephant\",startIndex = 1) == 1\n assert candidate(words = ['repeat', 'repeat', 'repeat'],target = \"repeat\",startIndex = 2) == 0\n assert candidate(words = ['north', 'south', 'east', 'west'],target = \"north\",startIndex = 3) == 1\n assert candidate(words = ['zebra', 'elephant', 'tiger', 'lion', 'giraffe'],target = \"tiger\",startIndex = 4) == 2\n assert candidate(words = ['loop', 'around', 'the', 'circular', 'array'],target = \"around\",startIndex = 2) == 1\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"six\",startIndex = 2) == -1\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],target = \"planet\",startIndex = 3) == 0\n assert candidate(words = ['one', 'two', 'three', 'four', 'five'],target = \"one\",startIndex = 4) == 1\n assert candidate(words = ['test', 'case', 'test'],target = \"test\",startIndex = 1) == 1\n assert candidate(words = ['up', 'down', 'left', 'right'],target = \"up\",startIndex = 3) == 1\n assert candidate(words = ['unique', 'words', 'only', 'here'],target = \"words\",startIndex = 3) == 2\n assert candidate(words = ['repeat', 'repeat', 'repeat'],target = \"repeat\",startIndex = 1) == 0\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta'],target = \"gamma\",startIndex = 2) == 0\n assert candidate(words = ['sun', 'moon', 'star', 'planet'],target = \"star\",startIndex = 3) == 1\n assert candidate(words = ['left', 'right', 'up', 'down'],target = \"up\",startIndex = 3) == 1\n assert candidate(words = ['one', 'two', 'three', 'four'],target = \"four\",startIndex = 3) == 0\n assert candidate(words = ['z', 'y', 'x', 'w', 'v'],target = \"x\",startIndex = 4) == 2\n assert candidate(words = ['a', 'a', 'a', 'a', 'a'],target = \"b\",startIndex = 0) == -1\n assert candidate(words = ['red', 'green', 'blue'],target = \"blue\",startIndex = 1) == 1\n assert candidate(words = ['search', 'for', 'the', 'target'],target = \"search\",startIndex = 3) == 1\n assert candidate(words = ['car', 'bus', 'train'],target = \"train\",startIndex = 1) == 1\n assert candidate(words = ['happy', 'sad', 'mad'],target = \"mad\",startIndex = 0) == 1\n assert candidate(words = ['dog', 'cat', 'bird', 'fish', 'dog'],target = \"fish\",startIndex = 0) == 2\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno'],target = \"ghi\",startIndex = 3) == 1\n assert candidate(words = ['red', 'blue', 'green'],target = \"blue\",startIndex = 2) == 1\n assert candidate(words = ['alpha', 'beta', 'gamma', 'delta', 'epsilon'],target = \"zeta\",startIndex = 2) == -1\n assert candidate(words = ['repeat', 'repeat', 'repeat'],target = \"repeat\",startIndex = 0) == 0\n", "comparison": "exact"}, "public_tests": ["[\"hello\",\"i\",\"am\",\"leetcode\",\"hello\"]\n\"hello\"\n1", "[\"a\",\"b\",\"leetcode\"]\n\"leetcode\"\n0", "[\"i\",\"eat\",\"leetcode\"]\n\"ate\"\n0"], "hints": ["You have two options, either move straight to the left or move straight to the right.", "Find the first target word and record the distance.", "Choose the one with the minimum distance."], "metadata": {"canonical_parameter_names": ["words", "target", "startIndex"], "leetcode_dataset_entry_point": "Solution().closestTarget", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:34+00:00", "tests_total": 247, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "string"]}, "language": "javascript", "interface": {"raw_signature": "var closestTarget = function(words, target, startIndex) {", "container": null, "callable": "closestTarget", "parameters": [{"name": "words", "type": "string[]"}, {"name": "target", "type": "string"}, {"name": "startIndex", "type": "number"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2516, "task_id": "take-k-of-each-character-from-left-and-right", "difficulty": "Medium", "problem_description": "You are given a string s consisting of the characters 'a', 'b', and 'c' and a non-negative integer k. Each minute, you may take either the leftmost character of s, or the rightmost character of s.\n\nReturn the minimum number of minutes needed for you to take at least k of each character, or return -1 if it is not possible to take k of each character.\n\nExample 1:\n\nInput: s = \"aabaaaacaabc\", k = 2\nOutput: 8\nExplanation:\nTake three characters from the left of s. You now have two 'a' characters, and one 'b' character.\nTake five characters from the right of s. You now have four 'a' characters, two 'b' characters, and two 'c' characters.\nA total of 3 + 5 = 8 minutes is needed.\nIt can be proven that 8 is the minimum number of minutes needed.\n\nExample 2:\n\nInput: s = \"a\", k = 1\nOutput: -1\nExplanation: It is not possible to take one 'b' or 'c' so return -1.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of only the letters 'a', 'b', and 'c'.\n- 0 <= k <= s.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abacbacbacb\",k = 2) == 6\n assert candidate(s = \"baccbaccbacc\",k = 2) == 6\n assert candidate(s = \"abcabcabcabcabc\",k = 3) == 9\n assert candidate(s = \"aabbaacc\",k = 2) == 6\n assert candidate(s = \"abc\",k = 0) == 0\n assert candidate(s = \"abcabcabcabcabcabc\",k = 3) == 9\n assert candidate(s = \"cccbbaaaa\",k = 2) == 7\n assert candidate(s = \"abacbcabc\",k = 0) == 0\n assert candidate(s = \"ccccccc\",k = 2) == -1\n assert candidate(s = \"aabbbccc\",k = 2) == 6\n assert candidate(s = \"aaaabbbbcccc\",k = 4) == 12\n assert candidate(s = \"aabaaaacaabc\",k = 2) == 8\n assert candidate(s = \"abcabcabc\",k = 1) == 3\n assert candidate(s = \"abcabcabc\",k = 3) == 9\n assert candidate(s = \"ccccccc\",k = 3) == -1\n assert candidate(s = \"a\",k = 1) == -1\n assert candidate(s = \"cccaaaabbb\",k = 2) == 7\n assert candidate(s = \"aabbcc\",k = 1) == 4\n assert candidate(s = \"aaabbbccc\",k = 3) == 9\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 4) == 12\n assert candidate(s = \"ccccccbbbaaa\",k = 3) == 9\n assert candidate(s = \"abacbacbacb\",k = 3) == 9\n assert candidate(s = \"aabbccaaabbcc\",k = 2) == 6\n assert candidate(s = \"abacbacbacbac\",k = 2) == 6\n assert candidate(s = \"baacababacbacbacbacbacb\",k = 3) == 9\n assert candidate(s = \"ababababababcabcabc\",k = 3) == 9\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",k = 5) == 15\n assert candidate(s = \"bababababababa\",k = 5) == -1\n assert candidate(s = \"aaaabbbbccccaaaabbbbccccaaaabbbbcccc\",k = 4) == 12\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\",k = 4) == 12\n assert candidate(s = \"bbbbbaaaaaccccaaaabbbbccccaaaa\",k = 5) == 18\n assert candidate(s = \"aabbbbccccaa\",k = 2) == 8\n assert candidate(s = \"abacabacabc\",k = 2) == 6\n assert candidate(s = \"aabacbacbacbac\",k = 3) == 9\n assert candidate(s = \"aabaaaabbbcccaabbcccaabbccc\",k = 3) == 9\n assert candidate(s = \"aabbbcccaaa\",k = 3) == 9\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",k = 6) == 18\n assert candidate(s = \"ccccbbbaaaa\",k = 3) == 10\n assert candidate(s = \"bbbbbcccccc\",k = 2) == -1\n assert candidate(s = \"cccaaaabbbccc\",k = 3) == 9\n assert candidate(s = \"abcbaabcbaabcba\",k = 2) == 6\n assert candidate(s = \"aaaaaaaaaabbbbbbbbcccccccc\",k = 4) == 16\n assert candidate(s = \"abacbacbacbacbacbacbacbacb\",k = 3) == 9\n assert candidate(s = \"ccbbbaaa\",k = 2) == 6\n assert candidate(s = \"aabbccaaaabbcc\",k = 3) == 10\n assert candidate(s = \"abccbaabccba\",k = 2) == 6\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbcccccc\",k = 5) == 16\n assert candidate(s = \"baccbaabccba\",k = 2) == 6\n assert candidate(s = \"abcabcabcabcabcabcabc\",k = 3) == 9\n assert candidate(s = \"abcabcabcabcabc\",k = 2) == 6\n assert candidate(s = \"cccccccccccccccccc\",k = 5) == -1\n assert candidate(s = \"cccccccccccaabbbbbb\",k = 3) == -1\n assert candidate(s = \"abacabacabac\",k = 3) == 11\n assert candidate(s = \"abacabaacaba\",k = 3) == -1\n assert candidate(s = \"aabbbcccbbbcccaaa\",k = 3) == 9\n assert candidate(s = \"abcabcabcabcabcabcabcabcabc\",k = 4) == 12\n assert candidate(s = \"abccbaabcbaabc\",k = 3) == 9\n assert candidate(s = \"ccccccbbbbaaa\",k = 2) == 7\n assert candidate(s = \"aaaaabbbbbcccc\",k = 1) == 6\n assert candidate(s = \"aaaaaaabbbccc\",k = 2) == 7\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 5) == 15\n assert candidate(s = \"aaabbbcccbbbcccaaaccc\",k = 4) == 14\n assert candidate(s = \"cccbbbbaaa\",k = 2) == 7\n assert candidate(s = \"aabbccabcabcabcabcabcabc\",k = 4) == 12\n assert candidate(s = \"aabaaaacaabc\",k = 5) == -1\n assert candidate(s = \"aabccbaabccbaabccba\",k = 3) == 9\n assert candidate(s = \"bbbbbbbccccaaa\",k = 2) == 7\n assert candidate(s = \"aaabbbcccaaa\",k = 2) == 8\n assert candidate(s = \"bbbaaabbbcccaaa\",k = 2) == 7\n assert candidate(s = \"abcabcabcabcabcabcabcabc\",k = 3) == 9\n assert candidate(s = \"abacbacbacbacbacbac\",k = 5) == 15\n assert candidate(s = \"aabaaabccbbccaa\",k = 3) == 10\n assert candidate(s = \"bacbacbacbacbac\",k = 4) == 12\n assert candidate(s = \"ccccaaabbb\",k = 2) == 7\n assert candidate(s = \"acbbacaabcbab\",k = 2) == 6\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 3) == 9\n assert candidate(s = \"abababababababababcabcabcabc\",k = 4) == 12\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcb\",k = 3) == -1\n assert candidate(s = \"abababababababababababababababababababababababab\",k = 5) == -1\n assert candidate(s = \"ccbaabacabcabcabcabcabcabcabcabcabcabc\",k = 4) == 12\n assert candidate(s = \"acbacbacbacbacbac\",k = 2) == 6\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",k = 10) == 30\n assert candidate(s = \"cccccccccccccccccccccccccccccccccccccccccccccc\",k = 15) == -1\n assert candidate(s = \"cccbaaaaabbccc\",k = 3) == 11\n assert candidate(s = \"aababababababababababababa\",k = 2) == -1\n assert candidate(s = \"aabbcccaabbcccaabbccc\",k = 5) == 16\n assert candidate(s = \"ccababacabac\",k = 2) == 6\n assert candidate(s = \"aabbaabbaabbaabbcc\",k = 4) == -1\n assert candidate(s = \"ccbacababacba\",k = 4) == 12\n assert candidate(s = \"aabaaaabbbcccaabbcccaabbccc\",k = 4) == 14\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabc\",k = 5) == 15\n assert candidate(s = \"cccccccccbaaaabbbccc\",k = 3) == 9\n assert candidate(s = \"bbaaccaabbbb\",k = 2) == 6\n assert candidate(s = \"abacbacbacbacbac\",k = 4) == 12\n assert candidate(s = \"caacbbacabcabc\",k = 2) == 6\n assert candidate(s = \"aabbccbaaabbccbaaabbcc\",k = 2) == 6\n assert candidate(s = \"cccccccccccbcccccccccc\",k = 3) == -1\n assert candidate(s = \"aabbcc\",k = 0) == 0\n assert candidate(s = \"cabcabcabcabcabcabcabcabcabcabcabc\",k = 5) == 15\n assert candidate(s = \"aabcaabcbaabcbaabcba\",k = 4) == 16\n assert candidate(s = \"ccccccbbbaaaaaaacccccccbbbaaaaaa\",k = 4) == 16\n assert candidate(s = \"abacabadabacaba\",k = 3) == -1\n assert candidate(s = \"bcccccccccccba\",k = 3) == -1\n assert candidate(s = \"aaabbbccc\",k = 0) == 0\n assert candidate(s = \"bcbcbcbcbcbc\",k = 2) == -1\n assert candidate(s = \"abcabcabcabcabcabc\",k = 2) == 6\n assert candidate(s = \"bacbacbacbacbacbacbacbacbacbacbacbac\",k = 4) == 12\n assert candidate(s = \"cccccccccccccccccccccccccc\",k = 10) == -1\n assert candidate(s = \"aabbbcccddd\",k = 1) == 7\n assert candidate(s = \"ccbaabccbaabccba\",k = 3) == 9\n assert candidate(s = \"ababababababababababababababababababababababababab\",k = 6) == -1\n assert candidate(s = \"ccccccaaaabbbb\",k = 2) == 8\n assert candidate(s = \"ccccbbbbaaaaccccbbaaaccccbbaa\",k = 4) == 12\n assert candidate(s = \"aabaaaacaabc\",k = 3) == -1\n assert candidate(s = \"bbbbbbbaaaaaaaccccccc\",k = 3) == 13\n assert candidate(s = \"cacacacacacaca\",k = 2) == -1\n assert candidate(s = \"bbacccbaaa\",k = 2) == 6\n assert candidate(s = \"bbbaaacccbbbaaacccbbbaaacccbbbaaaccc\",k = 3) == 9\n assert candidate(s = \"aabaaaacaabcbbbccc\",k = 3) == 9\n assert candidate(s = \"abcabcabcabcabcabcabc\",k = 4) == 12\n assert candidate(s = \"aabccccbaa\",k = 1) == 4\n assert candidate(s = \"aaaaabbbbbccccc\",k = 2) == 9\n assert candidate(s = \"abacabadabacabadabacabad\",k = 4) == -1\n assert candidate(s = \"ccccbbbaaa\",k = 2) == 7\n assert candidate(s = \"aaaaaaaaaaa\",k = 1) == -1\n assert candidate(s = \"abacabacabacabacabacabacabacabacabacabac\",k = 5) == 19\n assert candidate(s = \"aabbcc\",k = 2) == 6\n assert candidate(s = \"aabcaaacbbacabcabc\",k = 4) == 12\n", "comparison": "exact"}, "public_tests": ["\"aabaaaacaabc\"\n2", "\"a\"\n1"], "hints": ["Start by counting the frequency of each character and checking if it is possible.", "If you take x characters from the left side, what is the minimum number of characters you need to take from the right side? Find this for all values of x in the range 0 ≤ x ≤ s.length.", "Use a two-pointers approach to avoid computing the same information multiple times."], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().takeCharacters", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:37+00:00", "tests_total": 129, "tests_dropped": 1, "flags": [], "topic_tags": ["hash-table", "string", "sliding-window"]}, "language": "javascript", "interface": {"raw_signature": "var takeCharacters = function(s, k) {", "container": null, "callable": "takeCharacters", "parameters": [{"name": "s", "type": "string"}, {"name": "k", "type": "number"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2517, "task_id": "maximum-tastiness-of-candy-basket", "difficulty": "Medium", "problem_description": "You are given an array of positive integers price where price[i] denotes the price of the i^th candy and a positive integer k.\n\nThe store sells baskets of k distinct candies. The tastiness of a candy basket is the smallest absolute difference of the prices of any two candies in the basket.\n\nReturn the maximum tastiness of a candy basket.\n\nExample 1:\n\nInput: price = [13,5,1,8,21,2], k = 3\nOutput: 8\nExplanation: Choose the candies with the prices [13,5,21].\nThe tastiness of the candy basket is: min(|13 - 5|, |13 - 21|, |5 - 21|) = min(8, 8, 16) = 8.\nIt can be proven that 8 is the maximum tastiness that can be achieved.\n\nExample 2:\n\nInput: price = [1,3,1], k = 2\nOutput: 2\nExplanation: Choose the candies with the prices [1,3].\nThe tastiness of the candy basket is: min(|1 - 3|) = min(2) = 2.\nIt can be proven that 2 is the maximum tastiness that can be achieved.\n\nExample 3:\n\nInput: price = [7,7,7,7], k = 2\nOutput: 0\nExplanation: Choosing any two distinct candies from the candies we have will result in a tastiness of 0.\n\nConstraints:\n\n- 2 <= k <= price.length <= 10^5\n- 1 <= price[i] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(price = [1000000000, 1, 2, 3, 4, 5],k = 3) == 4\n assert candidate(price = [1000000000, 1, 1000000000, 1, 1000000000],k = 3) == 0\n assert candidate(price = [10, 20, 30, 40, 50],k = 3) == 20\n assert candidate(price = [13, 5, 1, 8, 21, 2],k = 3) == 8\n assert candidate(price = [1, 1000000000, 2, 999999999],k = 2) == 999999999\n assert candidate(price = [7, 7, 7, 7],k = 2) == 0\n assert candidate(price = [50, 50, 50, 50, 50, 50],k = 2) == 0\n assert candidate(price = [1, 3, 1],k = 2) == 2\n assert candidate(price = [10, 20, 30, 40, 50],k = 4) == 10\n assert candidate(price = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 2\n assert candidate(price = [100000000, 100000001, 100000002, 100000003, 100000004, 100000005, 100000006, 100000007, 100000008, 100000009],k = 5) == 2\n assert candidate(price = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 2) == 0\n assert candidate(price = [500, 400, 300, 200, 100, 90, 80, 70, 60, 50],k = 3) == 200\n assert candidate(price = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 5) == 0\n assert candidate(price = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == 20\n assert candidate(price = [1, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 5) == 6\n assert candidate(price = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 6) == 100\n assert candidate(price = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99],k = 6) == 18\n assert candidate(price = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 10) == 2\n assert candidate(price = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 3) == 2\n assert candidate(price = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997],k = 5) == 1\n assert candidate(price = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 9) == 20\n assert candidate(price = [100, 102, 105, 108, 110, 120, 130, 140, 150],k = 4) == 10\n assert candidate(price = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 6) == 63\n assert candidate(price = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946],k = 6) == 987\n assert candidate(price = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101, 105, 109, 113, 117],k = 10) == 12\n assert candidate(price = [500000000, 400000000, 300000000, 200000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1],k = 4) == 100000000\n assert candidate(price = [1000000000, 1, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10],k = 5) == 999999\n assert candidate(price = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],k = 6) == 30\n assert candidate(price = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],k = 8) == 6\n assert candidate(price = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],k = 5) == 2\n assert candidate(price = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 6) == 1\n assert candidate(price = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990],k = 5) == 2\n assert candidate(price = [987654321, 987654322, 987654323, 987654324, 987654325, 987654326, 987654327, 987654328, 987654329, 987654330],k = 7) == 1\n assert candidate(price = [1, 1000000000, 2, 999999999, 3, 999999998],k = 3) == 2\n assert candidate(price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 20\n assert candidate(price = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 2) == 1\n assert candidate(price = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 4\n assert candidate(price = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 4\n assert candidate(price = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],k = 6) == 1\n assert candidate(price = [999999999, 1, 1000000000, 2, 999999998, 3],k = 3) == 2\n assert candidate(price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 10\n assert candidate(price = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],k = 7) == 12\n assert candidate(price = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75],k = 12) == 6\n assert candidate(price = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],k = 5) == 2\n assert candidate(price = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 4\n assert candidate(price = [500000000, 500000001, 500000002, 500000003, 500000004, 500000005, 500000006, 500000007, 500000008, 500000009],k = 3) == 4\n assert candidate(price = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 4) == 1\n assert candidate(price = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 5) == 999999\n assert candidate(price = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80],k = 20) == 1\n assert candidate(price = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 8) == 200\n assert candidate(price = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 1\n assert candidate(price = [1000000000, 1, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1],k = 6) == 99999\n assert candidate(price = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 0\n assert candidate(price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 20\n assert candidate(price = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300],k = 8) == 40\n assert candidate(price = [1000000000, 900000000, 800000000, 700000000, 600000000, 500000000, 400000000, 300000000, 200000000, 100000000],k = 5) == 200000000\n assert candidate(price = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 12) == 10\n assert candidate(price = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 2\n assert candidate(price = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 0\n assert candidate(price = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 7) == 15\n assert candidate(price = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 2\n assert candidate(price = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 2\n assert candidate(price = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996],k = 5) == 2\n assert candidate(price = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],k = 5) == 2\n assert candidate(price = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000],k = 5) == 200000000\n assert candidate(price = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == 1\n assert candidate(price = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 5) == 999999\n assert candidate(price = [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 = 15) == 4\n assert candidate(price = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 2\n assert candidate(price = [5, 8, 12, 17, 22, 28, 33, 39, 44, 50],k = 5) == 11\n assert candidate(price = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000],k = 15) == 200\n assert candidate(price = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 2\n assert candidate(price = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2],k = 2) == 1\n assert candidate(price = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 10) == 2047\n assert candidate(price = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],k = 10) == 8\n assert candidate(price = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6],k = 4) == 1\n assert candidate(price = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 15) == 2\n assert candidate(price = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 7) == 100\n assert candidate(price = [524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 5) == 65535\n", "comparison": "exact"}, "public_tests": ["[13,5,1,8,21,2]\n3", "[1,3,1]\n2", "[7,7,7,7]\n2"], "hints": ["The answer is binary searchable.", "For some x, we can use a greedy strategy to check if it is possible to pick k distinct candies with tastiness being at least x.", "Sort prices and iterate from left to right. For some price[i] check if the price difference between the last taken candy and price[i] is at least x. If so, add the candy i to the basket.", "So, a candy basket with tastiness x can be achieved if the basket size is bigger than or equal to k."], "metadata": {"canonical_parameter_names": ["price", "k"], "leetcode_dataset_entry_point": "Solution().maximumTastiness", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:39+00:00", "tests_total": 81, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "binary-search", "greedy", "sorting"]}, "language": "javascript", "interface": {"raw_signature": "var maximumTastiness = function(price, k) {", "container": null, "callable": "maximumTastiness", "parameters": [{"name": "price", "type": "number[]"}, {"name": "k", "type": "number"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} @@ -476,7 +475,7 @@ {"question_id": 3232, "task_id": "find-if-digit-game-can-be-won", "difficulty": "Easy", "problem_description": "You are given an array of positive integers nums.\n\nAlice and Bob are playing a game. In the game, Alice can choose either all single-digit numbers or all double-digit numbers from nums, and the rest of the numbers are given to Bob. Alice wins if the sum of her numbers is strictly greater than the sum of Bob's numbers.\n\nReturn true if Alice can win this game, otherwise, return false.\n\nExample 1:\n\nInput: nums = [1,2,3,4,10]\nOutput: false\nExplanation:\nAlice cannot win by choosing either single-digit or double-digit numbers.\n\nExample 2:\n\nInput: nums = [1,2,3,4,5,14]\nOutput: true\nExplanation:\nAlice can win by choosing single-digit numbers which have a sum equal to 15.\n\nExample 3:\n\nInput: nums = [5,5,5,25]\nOutput: true\nExplanation:\nAlice can win by choosing double-digit numbers which have a sum equal to 25.\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- 1 <= nums[i] <= 99\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [9, 9, 9, 10, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 14]) == True\n assert candidate(nums = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [50, 25, 10, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == True\n assert candidate(nums = [1, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == True\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == True\n assert candidate(nums = [5, 5, 5, 25]) == True\n assert candidate(nums = [1, 11, 22, 33, 44, 55, 66, 77, 88, 99]) == True\n assert candidate(nums = [45, 46, 47, 48, 49, 50, 51, 52, 53, 54]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(nums = [1, 2, 3, 4, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [10, 20, 30, 40, 5]) == True\n assert candidate(nums = [50, 50, 50, 50, 50, 50]) == True\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10]) == True\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == True\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == True\n assert candidate(nums = [10, 10, 10, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == True\n assert candidate(nums = [9, 9, 9, 9, 9, 10, 10, 10]) == True\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 99]) == True\n assert candidate(nums = [10, 20, 30, 40]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48]) == True\n assert candidate(nums = [9, 99, 8, 88, 7, 77, 6, 66, 5, 55, 4, 44, 3, 33, 2, 22, 1, 11]) == True\n assert candidate(nums = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 1, 11, 21, 31, 41]) == True\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [55, 44, 33, 22, 11, 99, 88, 77, 66, 55, 44, 33]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(nums = [9, 12, 15, 20, 25, 30, 35, 40, 45, 50]) == True\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 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 = [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]) == True\n assert candidate(nums = [10, 20, 30, 40, 5, 15, 25, 35, 45, 55]) == True\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 99]) == True\n assert candidate(nums = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 2, 22, 32, 42, 52, 62, 72, 82, 92, 3, 33, 43, 53, 63, 73, 83, 93, 4, 44, 54, 64, 74, 84, 94, 5, 55, 65, 75, 85, 95, 6, 66, 76, 86, 96, 7, 77, 87, 97, 8, 88, 98, 9, 99, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\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, 1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, 15, 17, 18, 19, 21, 22, 23, 25, 26, 27, 29, 30, 31, 33, 34, 35, 37, 38, 39, 41, 42, 43, 45, 46, 47, 49, 50, 51, 53, 54, 55, 57, 58, 59, 61, 62, 63, 65, 66, 67, 69, 70, 71, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89, 90, 91, 93, 94, 95, 97, 98, 99]) == True\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 21, 32, 43, 54, 65, 76, 87, 98, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 21, 32, 43, 54, 65, 76, 87, 98, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 21, 32, 43, 54, 65, 76, 87, 98, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [8, 18, 28, 38, 48, 58, 68, 78, 88, 98, 9, 19, 29, 39, 49]) == True\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]) == True\n assert candidate(nums = [88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [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]) == 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, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 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 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9, 55]) == True\n assert candidate(nums = [1, 20, 3, 40, 5, 60, 7, 80, 9, 10]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 99]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 11, 22, 33, 44, 55, 66, 77, 88, 99, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 5, 15, 25, 35, 45]) == True\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 1, 11, 22, 33, 44]) == True\n assert candidate(nums = [99, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == True\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == True\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == True\n assert candidate(nums = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [45, 55, 65, 75, 85, 95, 5, 15, 25, 35, 45]) == True\n assert candidate(nums = [45, 55, 65, 75, 85, 95, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50]) == True\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 5, 10, 15, 20, 25, 30]) == True\n assert candidate(nums = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(nums = [12, 23, 34, 45, 56, 67, 78, 89, 90, 11]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98]) == True\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, 10, 20, 30, 40, 50]) == True\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]) == True\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == True\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41]) == True\n assert candidate(nums = [1, 11, 2, 22, 3, 33, 4, 44, 5, 55, 6, 66, 7, 77, 8, 88, 9, 99]) == True\n assert candidate(nums = [50, 40, 30, 20, 10, 1, 11, 21, 31, 41, 51, 61, 71, 81, 91]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [99, 88, 77, 66, 55, 44, 33, 22, 11, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [45, 54, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 1, 2, 3, 4, 6, 7, 8, 9]) == True\n assert candidate(nums = [41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == True\n assert candidate(nums = [5, 15, 25, 35, 45, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == True\n assert candidate(nums = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 2, 12, 22, 32, 42, 52, 62, 72, 82, 92]) == 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]) == True\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 10, 20, 30, 40, 50, 60, 70, 80, 90, 10, 20, 30, 40, 50, 60, 70, 80, 90, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 99, 88, 77, 66, 55, 44, 33, 22, 11]) == True\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 60, 70, 80, 90, 5]) == True\n assert candidate(nums = [8, 17, 26, 35, 44, 53, 62, 71, 80, 89, 10, 19, 28, 37, 46]) == True\n assert candidate(nums = [1, 12, 23, 34, 45, 56, 67, 78, 89, 90]) == True\n assert candidate(nums = [99, 88, 77, 66, 55, 44, 33, 22, 11, 1]) == True\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 10, 20, 30, 40, 50]) == True\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 50, 60, 70, 80, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 1, 2]) == True\n assert candidate(nums = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == True\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65]) == True\n assert candidate(nums = [1, 10, 2, 20, 3, 30, 4, 40, 5, 50, 6, 60, 7, 70, 8, 80, 9, 90]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [45, 55, 65, 75, 85, 95, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 15, 15, 15, 15, 15]) == True\n assert candidate(nums = [1, 12, 3, 45, 6, 78, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48, 49, 51, 52, 53, 54, 56, 57, 58, 59, 61, 62, 63, 64, 66, 67, 68, 69, 71, 72, 73, 74, 76, 77, 78, 79, 81, 82, 83, 84, 86, 87, 88, 89, 91, 92, 93, 94, 96, 97, 98, 99]) == True\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5, 94, 6, 93, 7, 92, 8, 91, 9, 90]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]) == True\n assert candidate(nums = [1, 12, 3, 14, 5, 16, 7, 18, 9, 10]) == True\n assert candidate(nums = [1, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]) == True\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 90, 81, 72, 63, 54, 45]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 99, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 1, 2, 3, 4, 6, 7, 8, 9]) == True\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,10]", "[1,2,3,4,5,14]", "[5,5,5,25]"], "hints": ["Alice wins if the sum of all single-digit numbers and the sum of all double-digit numbers are different."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().canAliceWin", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T21:17:50+00:00", "tests_total": 121, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "math"]}, "language": "javascript", "interface": {"raw_signature": "var canAliceWin = function(nums) {", "container": null, "callable": "canAliceWin", "parameters": [{"name": "nums", "type": "number[]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 3233, "task_id": "find-the-count-of-numbers-which-are-not-special", "difficulty": "Medium", "problem_description": "You are given 2 positive integers l and r. For any number x, all positive divisors of x except x are called the proper divisors of x.\n\nA number is called special if it has exactly 2 proper divisors. For example:\n\n- The number 4 is special because it has proper divisors 1 and 2.\n- The number 6 is not special because it has proper divisors 1, 2, and 3.\n\nReturn the count of numbers in the range [l, r] that are not special.\n\nExample 1:\n\nInput: l = 5, r = 7\nOutput: 3\nExplanation:\nThere are no special numbers in the range [5, 7].\n\nExample 2:\n\nInput: l = 4, r = 16\nOutput: 11\nExplanation:\nThe special numbers in the range [4, 16] are 4 and 9.\n\nConstraints:\n\n- 1 <= l <= r <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(l = 100,r = 200) == 99\n assert candidate(l = 5,r = 7) == 3\n assert candidate(l = 20,r = 50) == 29\n assert candidate(l = 1,r = 10) == 8\n assert candidate(l = 100,r = 150) == 50\n assert candidate(l = 4,r = 16) == 11\n assert candidate(l = 10,r = 20) == 11\n assert candidate(l = 1000,r = 10000) == 8987\n assert candidate(l = 25,r = 25) == 0\n assert candidate(l = 100000,r = 200000) == 99980\n assert candidate(l = 250000,r = 250100) == 101\n assert candidate(l = 1000000,r = 1000010) == 11\n assert candidate(l = 999999999,r = 1000000000) == 2\n assert candidate(l = 1,r = 100000000) == 99998771\n assert candidate(l = 100000,r = 150000) == 49990\n assert candidate(l = 1000000000,r = 1000000000) == 1\n assert candidate(l = 500000,r = 501000) == 1001\n assert candidate(l = 3,r = 3) == 1\n assert candidate(l = 1,r = 1000000) == 999832\n assert candidate(l = 5000,r = 6000) == 999\n assert candidate(l = 10000,r = 11000) == 999\n assert candidate(l = 2,r = 2) == 1\n assert candidate(l = 5000,r = 7000) == 1997\n assert candidate(l = 1000000,r = 1500000) == 499969\n assert candidate(l = 8,r = 8) == 1\n assert candidate(l = 1000000,r = 10000000) == 8999723\n assert candidate(l = 300000000,r = 400000000) == 99999729\n assert candidate(l = 500000,r = 1000000) == 499959\n assert candidate(l = 4,r = 1000000) == 999829\n assert candidate(l = 10000000,r = 10001000) == 1001\n assert candidate(l = 25,r = 50) == 24\n assert candidate(l = 1,r = 3) == 3\n assert candidate(l = 999999,r = 1000000) == 2\n assert candidate(l = 999900,r = 1000000) == 101\n assert candidate(l = 50,r = 100) == 51\n assert candidate(l = 8,r = 100) == 90\n assert candidate(l = 16,r = 25) == 9\n assert candidate(l = 1000000,r = 1001000) == 1001\n assert candidate(l = 16,r = 256) == 237\n assert candidate(l = 999,r = 1001) == 3\n assert candidate(l = 123456,r = 789012) == 665473\n assert candidate(l = 10000,r = 10100) == 101\n assert candidate(l = 999999950,r = 1000000000) == 51\n assert candidate(l = 50000,r = 60000) == 9996\n assert candidate(l = 123456,r = 123486) == 31\n assert candidate(l = 49,r = 50) == 1\n assert candidate(l = 97,r = 101) == 5\n assert candidate(l = 10000,r = 100000) == 89961\n assert candidate(l = 3000000,r = 3000100) == 101\n assert candidate(l = 500,r = 500) == 1\n assert candidate(l = 100000000,r = 100010000) == 10001\n assert candidate(l = 1234567,r = 8765432) == 7530626\n assert candidate(l = 150,r = 250) == 100\n assert candidate(l = 2,r = 3) == 2\n assert candidate(l = 8000000,r = 8000100) == 101\n assert candidate(l = 25,r = 36) == 11\n assert candidate(l = 987654,r = 987674) == 21\n assert candidate(l = 500,r = 1500) == 997\n assert candidate(l = 5000,r = 50000) == 44972\n assert candidate(l = 2000000,r = 2000050) == 51\n assert candidate(l = 500000,r = 500010) == 11\n assert candidate(l = 1,r = 100) == 96\n assert candidate(l = 500000,r = 600000) == 99990\n assert candidate(l = 1,r = 1000) == 989\n assert candidate(l = 1000,r = 2000) == 998\n assert candidate(l = 14,r = 28) == 14\n assert candidate(l = 100000000,r = 1000000000) == 899997829\n assert candidate(l = 1000000,r = 1000100) == 101\n assert candidate(l = 500000000,r = 600000000) == 99999786\n assert candidate(l = 101,r = 200) == 98\n assert candidate(l = 100,r = 1000) == 894\n assert candidate(l = 81,r = 81) == 1\n assert candidate(l = 49,r = 64) == 15\n assert candidate(l = 8,r = 25) == 16\n assert candidate(l = 5000,r = 7500) == 2497\n assert candidate(l = 25,r = 49) == 23\n assert candidate(l = 1000,r = 1500) == 500\n", "comparison": "exact"}, "public_tests": ["5\n7", "4\n16"], "hints": ["A special number must be a square of a prime number.", "We need to find all primes in the range [sqrt(l), sqrt(r)].", "Use sieve to find primes till sqrt(10^9)."], "metadata": {"canonical_parameter_names": ["l", "r"], "leetcode_dataset_entry_point": "Solution().nonSpecialCount", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T21:17:52+00:00", "tests_total": 77, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "math", "number-theory"]}, "language": "javascript", "interface": {"raw_signature": "var nonSpecialCount = function(l, r) {", "container": null, "callable": "nonSpecialCount", "parameters": [{"name": "l", "type": "number"}, {"name": "r", "type": "number"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 3234, "task_id": "count-the-number-of-substrings-with-dominant-ones", "difficulty": "Medium", "problem_description": "You are given a binary string s.\n\nReturn the number of substrings with dominant ones.\n\nA string has dominant ones if the number of ones in the string is greater than or equal to the square of the number of zeros in the string.\n\nExample 1:\n\nInput: s = \"00011\"\nOutput: 5\nExplanation:\nThe substrings with dominant ones are shown in the table below.\n\ni | j | s[i..j] | Number of Zeros | Number of Ones\n3 | 3 | 1 | 0 | 1\n4 | 4 | 1 | 0 | 1\n2 | 3 | 01 | 1 | 1\n3 | 4 | 11 | 0 | 2\n2 | 4 | 011 | 1 | 2\n\nExample 2:\n\nInput: s = \"101101\"\nOutput: 16\nExplanation:\nThe substrings with non-dominant ones are shown in the table below.\nSince there are 21 substrings total and 5 of them have non-dominant ones, it follows that there are 16 substrings with dominant ones.\n\ni | j | s[i..j] | Number of Zeros | Number of Ones\n1 | 1 | 0 | 1 | 0\n4 | 4 | 0 | 1 | 0\n1 | 4 | 0110 | 2 | 2\n0 | 4 | 10110 | 2 | 3\n1 | 5 | 01101 | 2 | 3\n\nConstraints:\n\n- 1 <= s.length <= 4 * 10^4\n- s consists only of characters '0' and '1'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == 10\n assert candidate(s = \"100100100\") == 8\n assert candidate(s = \"1111010101\") == 33\n assert candidate(s = \"000111000\") == 12\n assert candidate(s = \"11110000\") == 15\n assert candidate(s = \"0000\") == 0\n assert candidate(s = \"111000\") == 9\n assert candidate(s = \"01010101111\") == 34\n assert candidate(s = \"0011110011\") == 31\n assert candidate(s = \"0000101010\") == 11\n assert candidate(s = \"00001111\") == 15\n assert candidate(s = \"000111\") == 9\n assert candidate(s = \"1001001001\") == 10\n assert candidate(s = \"11111\") == 15\n assert candidate(s = \"01010101\") == 14\n assert candidate(s = \"11010101\") == 18\n assert candidate(s = \"10101010\") == 14\n assert candidate(s = \"1010100000\") == 10\n assert candidate(s = \"010101\") == 10\n assert candidate(s = \"1100111100\") == 31\n assert candidate(s = \"101010\") == 10\n assert candidate(s = \"00011\") == 5\n assert candidate(s = \"11001100\") == 13\n assert candidate(s = \"101101\") == 16\n assert candidate(s = \"111000111\") == 18\n assert candidate(s = \"1010101010101010\") == 30\n assert candidate(s = \"00000\") == 0\n assert candidate(s = \"10010010\") == 8\n assert candidate(s = \"000111000111000111000\") == 36\n assert candidate(s = \"111111111111111111111111\") == 300\n assert candidate(s = \"000011000110001100011000\") == 28\n assert candidate(s = \"1111110000000011\") == 35\n assert candidate(s = \"111000111000111000\") == 33\n assert candidate(s = \"1111000000000011111\") == 37\n assert candidate(s = \"000000111111000000111111\") == 70\n assert candidate(s = \"0110110110110110110\") == 88\n assert candidate(s = \"1101010101010101\") == 34\n assert candidate(s = \"111111111100000000000000000000\") == 74\n assert candidate(s = \"10101010101010101010101010101010101010101010101010\") == 98\n assert candidate(s = \"11000000001111111111\") == 79\n assert candidate(s = \"00111111001111110011111100111111001111110011111100111111001111110011\") == 657\n assert candidate(s = \"11110000000000000000000000000000000\") == 15\n assert candidate(s = \"111110000011111000001111100000\") == 82\n assert candidate(s = \"1100110011001100\") == 29\n assert candidate(s = \"00000000000000000000000000001111111\") == 39\n assert candidate(s = \"010101010101010101010101\") == 46\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100110011001100110\") == 133\n assert candidate(s = \"0001110001110001\") == 26\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001\") == 64\n assert candidate(s = \"000111000111000111\") == 33\n assert candidate(s = \"101010101010101010101010\") == 46\n assert candidate(s = \"1100000000000011\") == 10\n assert candidate(s = \"1000000000001000\") == 5\n assert candidate(s = \"111111111111111111111111111100000000000000000000\") == 496\n assert candidate(s = \"1000000000000011\") == 7\n assert candidate(s = \"010101010101010101\") == 34\n assert candidate(s = \"1000000000000000000000000000\") == 2\n assert candidate(s = \"111000111000111000111000111000\") == 57\n assert candidate(s = \"1111111000000000000\") == 39\n assert candidate(s = \"0000000000000000\") == 0\n assert candidate(s = \"11111000001111100000111110000011111\") == 104\n assert candidate(s = \"101010101010101010101010101010\") == 58\n assert candidate(s = \"0100111101110010\") == 60\n assert candidate(s = \"100100100100100100100\") == 20\n assert candidate(s = \"111100001111000011110000\") == 57\n assert candidate(s = \"0000000001111111110000000000\") == 80\n assert candidate(s = \"0011001100110011\") == 29\n assert candidate(s = \"11000011000011000011000011\") == 31\n assert candidate(s = \"0000111100001111000011110000\") == 63\n assert candidate(s = \"1000000010000000100000001\") == 10\n assert candidate(s = \"0000000000000000000000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"11111000000000001111111111\") == 96\n assert candidate(s = \"000000010000000100000001\") == 8\n assert candidate(s = \"100010001000100010001000\") == 17\n assert candidate(s = \"11111111111111111111000000000000\") == 264\n assert candidate(s = \"1001001001001001001001001001001\") == 31\n assert candidate(s = \"0000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"11110000111100001111\") == 51\n assert candidate(s = \"1111111110000000000000000000\") == 61\n assert candidate(s = \"010101010101010101010101010101010101010101010101\") == 94\n assert candidate(s = \"11111000001111100000111110000011111000001111100000111110000011111\") == 194\n assert candidate(s = \"111111111100000000001111111111\") == 148\n assert candidate(s = \"01010101010101010101010101010101010101010101010101\") == 98\n assert candidate(s = \"000000000000000000000000000000001111111111111111111111111111111\") == 601\n assert candidate(s = \"111000011111000\") == 39\n assert candidate(s = \"11111111111111111111\") == 210\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001\") == 52\n assert candidate(s = \"0000000000000000000000000000001111111111111111111111111111111\") == 601\n assert candidate(s = \"1111111111111111\") == 136\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111111\") == 2080\n assert candidate(s = \"0000000111111111111\") == 103\n assert candidate(s = \"0101010111111111\") == 96\n assert candidate(s = \"00000000000000000000000000000000111111111111111111111111111111111\") == 676\n assert candidate(s = \"111111000000111111000000111111\") == 100\n assert candidate(s = \"0000000001111111\") == 39\n assert candidate(s = \"0001010101101011\") == 37\n assert candidate(s = \"00000000001111111111\") == 74\n assert candidate(s = \"0011001100110011001100110011001100110011001100110011001100110011001\") == 129\n assert candidate(s = \"1111100000111110000011111\") == 74\n assert candidate(s = \"111000111000111000111\") == 42\n assert candidate(s = \"1001001001001001\") == 16\n assert candidate(s = \"11001100110011001100\") == 37\n assert candidate(s = \"01010101010101010101010101010101\") == 62\n assert candidate(s = \"1110010001100011110\") == 40\n assert candidate(s = \"1111000000000000000000000000000000000000\") == 15\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"1001001001001001001001\") == 22\n assert candidate(s = \"111000111000111000111000111\") == 54\n assert candidate(s = \"0000111111110000\") == 63\n assert candidate(s = \"0011110011110011\") == 65\n assert candidate(s = \"1111111100000000\") == 49\n assert candidate(s = \"1111000011110000111100001111000011110000\") == 99\n assert candidate(s = \"11100111001110011100111001110011100111001110011100\") == 171\n assert candidate(s = \"111110000111100001111\") == 58\n assert candidate(s = \"110000110000110000110000110000\") == 33\n assert candidate(s = \"0101010101010101\") == 30\n assert candidate(s = \"000000000000000000000000\") == 0\n assert candidate(s = \"111000111000111000111000111000111000111000111000\") == 93\n assert candidate(s = \"00000000000000000000000000000000000111111111111111\") == 154\n assert candidate(s = \"0000011111111100000\") == 80\n assert candidate(s = \"0000111111111111\") == 103\n assert candidate(s = \"000111000111000111000111000111\") == 57\n assert candidate(s = \"1000100010001000100\") == 14\n assert candidate(s = \"1001001001001001001\") == 19\n assert candidate(s = \"0110011001100110011001\") == 41\n assert candidate(s = \"11111111111111111000000000000000000000000000000000000000000000011\") == 200\n assert candidate(s = \"0010110101101011\") == 46\n assert candidate(s = \"000000000011111111110000000000\") == 96\n assert candidate(s = \"00000111110000011111000001111100000111110000011111000001111100000\") == 180\n assert candidate(s = \"11111111111111111111111111111111111111111111111111\") == 1275\n assert candidate(s = \"11011011011011011011011011011011011\") == 184\n assert candidate(s = \"1110001110001110\") == 33\n assert candidate(s = \"10010010010010010010010010010010\") == 32\n assert candidate(s = \"1110011100011100011\") == 44\n assert candidate(s = \"00000000000000000000\") == 0\n assert candidate(s = \"1111000011110000\") == 36\n assert candidate(s = \"10101010101010101010101010101010\") == 62\n assert candidate(s = \"01001001001001001001001\") == 23\n assert candidate(s = \"1111111111000000\") == 74\n assert candidate(s = \"0000000011111111\") == 49\n assert candidate(s = \"1111000000001111\") == 30\n assert candidate(s = \"01001001001001001001001001001001\") == 32\n assert candidate(s = \"1000001111110000\") == 42\n assert candidate(s = \"000000000011111111111111111111\") == 264\n assert candidate(s = \"1100001100001100\") == 19\n assert candidate(s = \"1111111111\") == 55\n assert candidate(s = \"1010101010101010101010101010101010101010\") == 78\n assert candidate(s = \"0110011001100110\") == 31\n assert candidate(s = \"1111000000000000111111111111\") == 118\n assert candidate(s = \"1111000011110000111100001111\") == 72\n assert candidate(s = \"00000000000000000001\") == 2\n assert candidate(s = \"0000000000111111\") == 30\n assert candidate(s = \"0011001100110011001100110011\") == 53\n assert candidate(s = \"01010101010101010101\") == 38\n assert candidate(s = \"111110111110111110111110111110\") == 453\n assert candidate(s = \"111110000000\") == 22\n assert candidate(s = \"1111111101010101\") == 84\n assert candidate(s = \"1101001010010100\") == 24\n assert candidate(s = \"1111010101010101\") == 45\n assert candidate(s = \"000001111100000111110000011111\") == 82\n assert candidate(s = \"0000000000000000000000000001\") == 2\n assert candidate(s = \"10101010101010101010\") == 38\n assert candidate(s = \"0110110110110110110110110110110\") == 156\n assert candidate(s = \"11111111111111110000000000\") == 174\n assert candidate(s = \"0000111100001111\") == 36\n", "comparison": "exact"}, "public_tests": ["\"00011\"", "\"101101\""], "hints": ["Let us fix the starting index l of the substring and count the number of indices r such that l <= r and the substring s[l..r] has dominant ones.", "A substring with dominant ones has at most sqrt(n) zeros.", "We cannot iterate over every r and check if the s[l..r] has dominant ones. Instead, we iterate over the next sqrt(n) zeros to the left of l and count the number of substrings with dominant ones where the current zero is the rightmost zero of the substring."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numberOfSubstrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T21:17:54+00:00", "tests_total": 165, "tests_dropped": 0, "flags": ["figure_reference"], "topic_tags": ["string", "enumeration"]}, "language": "javascript", "interface": {"raw_signature": "var numberOfSubstrings = function(s) {", "container": null, "callable": "numberOfSubstrings", "parameters": [{"name": "s", "type": "string"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3235, "task_id": "check-if-the-rectangle-corner-is-reachable", "difficulty": "Hard", "problem_description": "You are given two positive integers xCorner and yCorner, and a 2D array circles, where circles[i] = [x_i, y_i, r_i] denotes a circle with center at (x_i, y_i) and radius r_i.\n\nThere is a rectangle in the coordinate plane with its bottom left corner at the origin and top right corner at the coordinate (xCorner, yCorner). You need to check whether there is a path from the bottom left corner to the top right corner such that the entire path lies inside the rectangle, does not touch or lie inside any circle, and touches the rectangle only at the two corners.\n\nReturn true if such a path exists, and false otherwise.\n\nExample 1:\n\nInput: xCorner = 3, yCorner = 4, circles = [[2,1,1]]\nOutput: true\nExplanation:\nThe black curve shows a possible path between (0, 0) and (3, 4).\n\nExample 2:\n\nInput: xCorner = 3, yCorner = 3, circles = [[1,1,2]]\nOutput: false\nExplanation:\nNo path exists from (0, 0) to (3, 3).\n\nExample 3:\n\nInput: xCorner = 3, yCorner = 3, circles = [[2,1,1],[1,2,1]]\nOutput: false\nExplanation:\nNo path exists from (0, 0) to (3, 3).\n\nExample 4:\n\nInput: xCorner = 4, yCorner = 4, circles = [[5,5,1]]\nOutput: true\nExplanation:\n\nConstraints:\n\n- 3 <= xCorner, yCorner <= 10^9\n- 1 <= circles.length <= 1000\n- circles[i].length == 3\n- 1 <= x_i, y_i, r_i <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 1, 1], [9, 9, 1]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 499999999]]) == True\n assert candidate(xCorner = 5,yCorner = 5,circles = [[1, 1, 1], [4, 4, 1], [2, 2, 1]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 100000000]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[5, 5, 2], [2, 2, 1]]) == True\n assert candidate(xCorner = 5,yCorner = 5,circles = [[2, 2, 1], [3, 3, 1]]) == True\n assert candidate(xCorner = 5,yCorner = 5,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 500000000]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 1]]) == True\n assert candidate(xCorner = 3,yCorner = 3,circles = [[2, 1, 1], [1, 2, 1]]) == False\n assert candidate(xCorner = 3,yCorner = 4,circles = [[2, 1, 1]]) == True\n assert candidate(xCorner = 4,yCorner = 4,circles = [[5, 5, 1]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[5, 5, 1], [3, 3, 2]]) == True\n assert candidate(xCorner = 3,yCorner = 3,circles = [[1, 1, 2]]) == False\n assert candidate(xCorner = 15,yCorner = 15,circles = [[3, 3, 3], [12, 12, 3], [7, 7, 2], [9, 9, 1]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 500000000]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[10, 10, 5], [15, 15, 3], [5, 5, 2], [18, 2, 1], [2, 18, 1]]) == True\n assert candidate(xCorner = 25,yCorner = 25,circles = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]]) == False\n assert candidate(xCorner = 8,yCorner = 8,circles = [[2, 2, 3], [6, 6, 3]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[5, 5, 2], [2, 2, 3], [8, 8, 3]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 5, 1], [9, 5, 1], [5, 1, 1], [5, 9, 1], [2, 2, 2], [8, 2, 2], [2, 8, 2], [8, 8, 2]]) == False\n assert candidate(xCorner = 8,yCorner = 8,circles = [[4, 4, 2], [2, 2, 1], [6, 6, 1], [1, 7, 2], [7, 1, 2]]) == True\n assert candidate(xCorner = 1000000,yCorner = 1000000,circles = [[500000, 500000, 300000], [300000, 300000, 100000], [700000, 700000, 100000], [100000, 100000, 50000], [900000, 900000, 50000], [100000, 900000, 50000], [900000, 100000, 50000], [500000, 100000, 200000], [500000, 900000, 200000]]) == False\n assert candidate(xCorner = 15,yCorner = 15,circles = [[1, 1, 1], [14, 14, 1], [7, 7, 5]]) == False\n assert candidate(xCorner = 7,yCorner = 7,circles = [[3, 3, 1], [4, 3, 1], [3, 4, 1], [4, 4, 1], [2, 2, 1], [2, 3, 1], [3, 2, 1], [2, 4, 1], [4, 2, 1]]) == True\n assert candidate(xCorner = 30,yCorner = 30,circles = [[1, 1, 1], [29, 29, 1], [15, 15, 10], [15, 15, 5]]) == False\n assert candidate(xCorner = 9,yCorner = 9,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[5, 5, 4], [2, 2, 1], [8, 8, 1], [1, 1, 1], [9, 9, 1], [4, 1, 1], [1, 4, 1], [8, 4, 1], [4, 8, 1]]) == False\n assert candidate(xCorner = 3,yCorner = 10,circles = [[2, 5, 1], [1, 3, 1], [2, 8, 1], [1, 7, 1], [2, 2, 1], [1, 1, 1], [2, 9, 1], [1, 9, 1]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 5, 2], [5, 1, 2], [5, 9, 2], [9, 5, 2]]) == True\n assert candidate(xCorner = 15,yCorner = 15,circles = [[1, 1, 1], [15, 15, 1], [1, 15, 1], [15, 1, 1], [8, 8, 3], [7, 7, 2], [9, 9, 2]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[1, 1, 1], [1, 20, 1], [20, 1, 1], [20, 20, 1], [10, 10, 5]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[999999999, 999999999, 1], [500000000, 500000000, 500000000]]) == False\n assert candidate(xCorner = 9,yCorner = 9,circles = [[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], [1, 9, 2], [9, 1, 2], [4.5, 4.5, 3]]) == False\n assert candidate(xCorner = 50,yCorner = 50,circles = [[5, 5, 5], [45, 45, 5], [25, 25, 10], [15, 15, 3], [35, 35, 3]]) == False\n assert candidate(xCorner = 150,yCorner = 150,circles = [[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]]) == False\n assert candidate(xCorner = 20,yCorner = 15,circles = [[10, 10, 5], [15, 15, 3], [5, 5, 4]]) == True\n assert candidate(xCorner = 15,yCorner = 20,circles = [[1, 1, 1], [14, 19, 1], [8, 10, 2], [7, 8, 2], [9, 8, 2], [8, 7, 2], [8, 9, 2]]) == False\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 25, 20], [50, 75, 20], [25, 50, 20], [75, 50, 20]]) == True\n assert candidate(xCorner = 500,yCorner = 500,circles = [[100, 100, 50], [400, 400, 50], [250, 250, 150], [250, 250, 100]]) == True\n assert candidate(xCorner = 999999999,yCorner = 999999999,circles = [[500000000, 500000000, 100000000], [900000000, 900000000, 100000000], [100000000, 100000000, 100000000]]) == False\n assert candidate(xCorner = 500,yCorner = 500,circles = [[250, 250, 150], [100, 100, 50], [400, 400, 50], [50, 50, 20], [450, 450, 20], [100, 450, 20], [450, 100, 20], [250, 50, 100], [250, 450, 100]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[5, 5, 2], [5, 5, 1]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[3, 3, 1], [6, 6, 1], [2, 8, 2], [8, 2, 2]]) == True\n assert candidate(xCorner = 1000,yCorner = 1000,circles = [[500, 500, 300], [300, 300, 100], [700, 700, 100], [100, 100, 50], [900, 900, 50], [100, 900, 50], [900, 100, 50], [500, 100, 200], [500, 900, 200]]) == False\n assert candidate(xCorner = 6,yCorner = 8,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [1, 8, 1], [6, 1, 1]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[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]]) == False\n assert candidate(xCorner = 100,yCorner = 100,circles = [[25, 25, 20], [75, 75, 20], [50, 50, 20], [25, 75, 20], [75, 25, 20]]) == True\n assert candidate(xCorner = 9,yCorner = 9,circles = [[2, 2, 2], [2, 6, 2], [6, 2, 2], [6, 6, 2], [5, 5, 1]]) == False\n assert candidate(xCorner = 7,yCorner = 7,circles = [[2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1]]) == False\n assert candidate(xCorner = 1000000,yCorner = 1000000,circles = [[100000, 100000, 50000], [900000, 900000, 50000], [500000, 500000, 150000], [500000, 500000, 100000]]) == True\n assert candidate(xCorner = 7,yCorner = 7,circles = [[1, 6, 1], [2, 5, 1], [3, 4, 1], [4, 3, 1], [5, 2, 1], [6, 1, 1], [7, 7, 1], [7, 6, 1], [7, 5, 1], [7, 4, 1], [7, 3, 1], [7, 2, 1], [7, 1, 1]]) == False\n assert candidate(xCorner = 30,yCorner = 40,circles = [[15, 20, 5], [10, 25, 6], [20, 10, 4], [5, 30, 3], [25, 5, 2]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 30], [70, 70, 20], [30, 30, 25], [10, 10, 10], [90, 90, 10]]) == False\n assert candidate(xCorner = 12,yCorner = 12,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1], [11, 11, 1], [12, 12, 1], [1, 12, 1], [12, 1, 1]]) == False\n assert candidate(xCorner = 12,yCorner = 12,circles = [[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], [10, 10, 2], [11, 11, 2]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[5, 10, 3], [10, 5, 3], [10, 15, 3], [15, 10, 3], [10, 10, 5]]) == True\n assert candidate(xCorner = 8,yCorner = 8,circles = [[1, 8, 1], [8, 1, 1], [4, 4, 2], [2, 2, 1], [6, 6, 1], [5, 5, 1], [3, 3, 1], [7, 7, 1]]) == False\n assert candidate(xCorner = 10,yCorner = 3,circles = [[5, 2, 1], [4, 2, 1], [6, 2, 1], [3, 2, 1], [7, 2, 1], [2, 2, 1], [8, 2, 1], [5, 1, 1]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[1, 1, 1], [20, 20, 1], [10, 10, 5], [15, 5, 3]]) == False\n assert candidate(xCorner = 25,yCorner = 25,circles = [[5, 10, 5], [10, 5, 5], [20, 20, 5], [15, 15, 5], [25, 5, 5], [5, 25, 5]]) == False\n assert candidate(xCorner = 50,yCorner = 50,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [45, 45, 1], [46, 46, 1], [47, 47, 1], [48, 48, 1], [49, 49, 1]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 1, 1], [9, 9, 1], [5, 5, 2], [3, 3, 1], [7, 7, 1]]) == False\n assert candidate(xCorner = 15,yCorner = 15,circles = [[8, 8, 3], [7, 7, 2], [6, 6, 1], [9, 9, 2], [10, 10, 3], [11, 11, 4]]) == False\n assert candidate(xCorner = 50,yCorner = 50,circles = [[10, 10, 5], [20, 20, 5], [30, 30, 5], [40, 40, 5], [50, 50, 5]]) == False\n assert candidate(xCorner = 80,yCorner = 60,circles = [[10, 10, 10], [20, 20, 10], [30, 30, 10], [40, 40, 10], [50, 50, 10], [60, 60, 10], [70, 70, 10]]) == False\n assert candidate(xCorner = 10000,yCorner = 10000,circles = [[1000, 1000, 500], [9000, 9000, 500], [5000, 5000, 1500], [5000, 5000, 1000]]) == True\n assert candidate(xCorner = 7,yCorner = 7,circles = [[1, 1, 1], [1, 7, 1], [7, 1, 1], [7, 7, 1], [3, 4, 1], [4, 3, 1], [4, 5, 1], [5, 4, 1]]) == False\n assert candidate(xCorner = 9,yCorner = 9,circles = [[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]]) == False\n assert candidate(xCorner = 30,yCorner = 40,circles = [[10, 10, 5], [20, 20, 10], [5, 5, 2], [25, 25, 4]]) == True\n assert candidate(xCorner = 50,yCorner = 50,circles = [[25, 25, 10], [30, 30, 15], [20, 20, 5], [10, 40, 5]]) == True\n assert candidate(xCorner = 100000,yCorner = 100000,circles = [[10000, 10000, 5000], [90000, 90000, 5000], [50000, 50000, 15000], [50000, 50000, 10000]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 20], [30, 30, 5], [70, 70, 5], [10, 10, 2], [90, 90, 2], [10, 90, 2], [90, 10, 2], [50, 10, 10], [50, 90, 10]]) == True\n assert candidate(xCorner = 500000000,yCorner = 500000000,circles = [[250000000, 250000000, 100000000], [300000000, 300000000, 150000000]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[10, 10, 5], [90, 90, 5], [50, 50, 20], [50, 50, 10]]) == True\n assert candidate(xCorner = 1000,yCorner = 1000,circles = [[100, 100, 100], [900, 900, 100], [500, 500, 500], [300, 700, 200], [700, 300, 200]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 500000000], [1000000000, 1000000000, 1]]) == False\n assert candidate(xCorner = 1000,yCorner = 1000,circles = [[1, 1, 1], [1000, 1000, 1], [500, 500, 100], [900, 900, 50]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 499999999], [1000000000, 1000000000, 1]]) == False\n assert candidate(xCorner = 9,yCorner = 9,circles = [[3, 3, 2], [6, 6, 2], [4, 4, 1], [5, 5, 1]]) == True\n assert candidate(xCorner = 50,yCorner = 50,circles = [[25, 25, 10], [10, 10, 5], [40, 40, 5], [5, 5, 2], [45, 45, 2], [10, 40, 2], [40, 10, 2]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 10], [40, 40, 10], [60, 60, 10], [50, 30, 10], [50, 70, 10]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 1, 1], [9, 9, 1], [5, 5, 2], [2, 5, 1], [5, 2, 1]]) == False\n assert candidate(xCorner = 50,yCorner = 50,circles = [[10, 10, 5], [20, 20, 5], [30, 30, 5], [40, 40, 5]]) == True\n assert candidate(xCorner = 1000,yCorner = 1000,circles = [[100, 100, 100], [900, 900, 100], [500, 500, 300], [500, 500, 200]]) == False\n assert candidate(xCorner = 25,yCorner = 25,circles = [[5, 5, 4], [20, 20, 4], [15, 15, 4], [10, 10, 3], [25, 25, 1]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[5, 5, 4], [15, 15, 4], [10, 10, 6]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 10], [20, 20, 5], [80, 80, 5], [10, 10, 2], [90, 90, 2], [10, 90, 2], [90, 10, 2], [50, 10, 5], [50, 90, 5], [10, 50, 5], [90, 50, 5]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 1, 2], [9, 9, 2], [5, 5, 3]]) == False\n assert candidate(xCorner = 50,yCorner = 50,circles = [[10, 10, 5], [40, 40, 5], [10, 40, 5], [40, 10, 5], [25, 25, 10]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[2, 2, 2], [3, 3, 1], [4, 4, 2], [5, 5, 1], [6, 6, 2], [7, 7, 1], [8, 8, 2]]) == False\n assert candidate(xCorner = 100,yCorner = 50,circles = [[25, 25, 15], [75, 25, 15], [50, 45, 10]]) == True\n assert candidate(xCorner = 15,yCorner = 15,circles = [[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], [10, 10, 2], [11, 11, 2], [12, 12, 2], [13, 13, 2], [14, 14, 2]]) == False\n assert candidate(xCorner = 25,yCorner = 25,circles = [[5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1], [11, 11, 1], [12, 12, 1], [13, 13, 1], [14, 14, 1], [15, 15, 1], [16, 16, 1], [17, 17, 1], [18, 18, 1], [19, 19, 1], [20, 20, 1], [21, 21, 1], [22, 22, 1], [23, 23, 1], [24, 24, 1], [25, 25, 1], [1, 1, 12], [25, 25, 12]]) == False\n assert candidate(xCorner = 100,yCorner = 100,circles = [[25, 25, 20], [75, 75, 20], [50, 50, 10], [10, 90, 10], [90, 10, 10]]) == True\n assert candidate(xCorner = 999999999,yCorner = 999999999,circles = [[499999999, 499999999, 100000000], [500000000, 500000000, 200000000]]) == True\n assert candidate(xCorner = 999999999,yCorner = 999999999,circles = [[999999999, 999999999, 10], [1, 1, 100], [500000000, 500000000, 1000000]]) == False\n assert candidate(xCorner = 18,yCorner = 18,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1], [11, 11, 1], [12, 12, 1], [13, 13, 1], [14, 14, 1], [15, 15, 1], [16, 16, 1], [17, 17, 1], [18, 18, 1], [9, 9, 5]]) == False\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 20], [30, 70, 15], [70, 30, 15], [10, 10, 5], [90, 90, 5], [20, 20, 3], [80, 80, 3]]) == True\n assert candidate(xCorner = 12,yCorner = 12,circles = [[6, 6, 3], [3, 3, 2], [9, 9, 2], [1, 1, 1], [11, 11, 1]]) == False\n assert candidate(xCorner = 18,yCorner = 18,circles = [[9, 9, 5], [1, 1, 1], [17, 17, 1], [1, 17, 1], [17, 1, 1], [5, 5, 1], [13, 13, 1], [7, 13, 1], [13, 7, 1]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[5, 5, 3], [10, 10, 3], [15, 15, 3], [2, 2, 1], [18, 18, 1]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[3, 3, 2], [7, 7, 2], [5, 5, 1]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 40], [70, 30, 20], [30, 70, 25], [10, 10, 5], [90, 90, 5]]) == True\n assert candidate(xCorner = 20,yCorner = 20,circles = [[5, 5, 1], [15, 15, 1], [10, 10, 5], [5, 15, 1], [15, 5, 1]]) == True\n", "comparison": "exact"}, "public_tests": ["3\n4\n[[2,1,1]]", "3\n3\n[[1,1,2]]", "3\n3\n[[2,1,1],[1,2,1]]", "4\n4\n[[5,5,1]]"], "hints": ["Create a graph with n + 4 vertices.", "Vertices 0 to n - 1 represent the circles, vertex n represents upper edge, vertex n + 1 represents right edge, vertex n + 2 represents lower edge, and vertex n + 3 represents left edge.", "Add an edge between these vertices if they intersect or touch.", "Answer will be false when any of two sides left-right, left-bottom, right-top or top-bottom are reachable using the edges."], "metadata": {"canonical_parameter_names": ["xCorner", "yCorner", "circles"], "leetcode_dataset_entry_point": "Solution().canReachCorner", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T21:17:56+00:00", "tests_total": 105, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "math", "depth-first-search", "breadth-first-search", "union-find", "geometry"]}, "language": "javascript", "interface": {"raw_signature": "var canReachCorner = function(xCorner, yCorner, circles) {", "container": null, "callable": "canReachCorner", "parameters": [{"name": "xCorner", "type": "number"}, {"name": "yCorner", "type": "number"}, {"name": "circles", "type": "number[][]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 3235, "task_id": "check-if-the-rectangle-corner-is-reachable", "difficulty": "Hard", "problem_description": "You are given two positive integers xCorner and yCorner, and a 2D array circles, where circles[i] = [x_i, y_i, r_i] denotes a circle with center at (x_i, y_i) and radius r_i.\n\nThere is a rectangle in the coordinate plane with its bottom left corner at the origin and top right corner at the coordinate (xCorner, yCorner). You need to check whether there is a path from the bottom left corner to the top right corner such that the entire path lies inside the rectangle, does not touch or lie inside any circle, and touches the rectangle only at the two corners.\n\nReturn true if such a path exists, and false otherwise.\n\nExample 1:\n\nInput: xCorner = 3, yCorner = 4, circles = [[2,1,1]]\nOutput: true\nExplanation:\nThe black curve shows a possible path between (0, 0) and (3, 4).\n\nExample 2:\n\nInput: xCorner = 3, yCorner = 3, circles = [[1,1,2]]\nOutput: false\nExplanation:\nNo path exists from (0, 0) to (3, 3).\n\nExample 3:\n\nInput: xCorner = 3, yCorner = 3, circles = [[2,1,1],[1,2,1]]\nOutput: false\nExplanation:\nNo path exists from (0, 0) to (3, 3).\n\nExample 4:\n\nInput: xCorner = 4, yCorner = 4, circles = [[5,5,1]]\nOutput: true\nExplanation:\n\nConstraints:\n\n- 3 <= xCorner, yCorner <= 10^9\n- 1 <= circles.length <= 1000\n- circles[i].length == 3\n- 1 <= x_i, y_i, r_i <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 1, 1], [9, 9, 1]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 499999999]]) == True\n assert candidate(xCorner = 5,yCorner = 5,circles = [[1, 1, 1], [4, 4, 1], [2, 2, 1]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 100000000]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[5, 5, 2], [2, 2, 1]]) == True\n assert candidate(xCorner = 5,yCorner = 5,circles = [[2, 2, 1], [3, 3, 1]]) == True\n assert candidate(xCorner = 5,yCorner = 5,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 500000000]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 1]]) == True\n assert candidate(xCorner = 3,yCorner = 3,circles = [[2, 1, 1], [1, 2, 1]]) == False\n assert candidate(xCorner = 3,yCorner = 4,circles = [[2, 1, 1]]) == True\n assert candidate(xCorner = 4,yCorner = 4,circles = [[5, 5, 1]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[5, 5, 1], [3, 3, 2]]) == True\n assert candidate(xCorner = 3,yCorner = 3,circles = [[1, 1, 2]]) == False\n assert candidate(xCorner = 15,yCorner = 15,circles = [[3, 3, 3], [12, 12, 3], [7, 7, 2], [9, 9, 1]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 500000000]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[10, 10, 5], [15, 15, 3], [5, 5, 2], [18, 2, 1], [2, 18, 1]]) == True\n assert candidate(xCorner = 25,yCorner = 25,circles = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]]) == False\n assert candidate(xCorner = 8,yCorner = 8,circles = [[2, 2, 3], [6, 6, 3]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[5, 5, 2], [2, 2, 3], [8, 8, 3]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 5, 1], [9, 5, 1], [5, 1, 1], [5, 9, 1], [2, 2, 2], [8, 2, 2], [2, 8, 2], [8, 8, 2]]) == False\n assert candidate(xCorner = 8,yCorner = 8,circles = [[4, 4, 2], [2, 2, 1], [6, 6, 1], [1, 7, 2], [7, 1, 2]]) == True\n assert candidate(xCorner = 1000000,yCorner = 1000000,circles = [[500000, 500000, 300000], [300000, 300000, 100000], [700000, 700000, 100000], [100000, 100000, 50000], [900000, 900000, 50000], [100000, 900000, 50000], [900000, 100000, 50000], [500000, 100000, 200000], [500000, 900000, 200000]]) == False\n assert candidate(xCorner = 15,yCorner = 15,circles = [[1, 1, 1], [14, 14, 1], [7, 7, 5]]) == False\n assert candidate(xCorner = 7,yCorner = 7,circles = [[3, 3, 1], [4, 3, 1], [3, 4, 1], [4, 4, 1], [2, 2, 1], [2, 3, 1], [3, 2, 1], [2, 4, 1], [4, 2, 1]]) == True\n assert candidate(xCorner = 30,yCorner = 30,circles = [[1, 1, 1], [29, 29, 1], [15, 15, 10], [15, 15, 5]]) == False\n assert candidate(xCorner = 9,yCorner = 9,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[5, 5, 4], [2, 2, 1], [8, 8, 1], [1, 1, 1], [9, 9, 1], [4, 1, 1], [1, 4, 1], [8, 4, 1], [4, 8, 1]]) == False\n assert candidate(xCorner = 3,yCorner = 10,circles = [[2, 5, 1], [1, 3, 1], [2, 8, 1], [1, 7, 1], [2, 2, 1], [1, 1, 1], [2, 9, 1], [1, 9, 1]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 5, 2], [5, 1, 2], [5, 9, 2], [9, 5, 2]]) == True\n assert candidate(xCorner = 15,yCorner = 15,circles = [[1, 1, 1], [15, 15, 1], [1, 15, 1], [15, 1, 1], [8, 8, 3], [7, 7, 2], [9, 9, 2]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[1, 1, 1], [1, 20, 1], [20, 1, 1], [20, 20, 1], [10, 10, 5]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[999999999, 999999999, 1], [500000000, 500000000, 500000000]]) == False\n assert candidate(xCorner = 50,yCorner = 50,circles = [[5, 5, 5], [45, 45, 5], [25, 25, 10], [15, 15, 3], [35, 35, 3]]) == False\n assert candidate(xCorner = 150,yCorner = 150,circles = [[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]]) == False\n assert candidate(xCorner = 20,yCorner = 15,circles = [[10, 10, 5], [15, 15, 3], [5, 5, 4]]) == True\n assert candidate(xCorner = 15,yCorner = 20,circles = [[1, 1, 1], [14, 19, 1], [8, 10, 2], [7, 8, 2], [9, 8, 2], [8, 7, 2], [8, 9, 2]]) == False\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 25, 20], [50, 75, 20], [25, 50, 20], [75, 50, 20]]) == True\n assert candidate(xCorner = 500,yCorner = 500,circles = [[100, 100, 50], [400, 400, 50], [250, 250, 150], [250, 250, 100]]) == True\n assert candidate(xCorner = 999999999,yCorner = 999999999,circles = [[500000000, 500000000, 100000000], [900000000, 900000000, 100000000], [100000000, 100000000, 100000000]]) == False\n assert candidate(xCorner = 500,yCorner = 500,circles = [[250, 250, 150], [100, 100, 50], [400, 400, 50], [50, 50, 20], [450, 450, 20], [100, 450, 20], [450, 100, 20], [250, 50, 100], [250, 450, 100]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[5, 5, 2], [5, 5, 1]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[3, 3, 1], [6, 6, 1], [2, 8, 2], [8, 2, 2]]) == True\n assert candidate(xCorner = 1000,yCorner = 1000,circles = [[500, 500, 300], [300, 300, 100], [700, 700, 100], [100, 100, 50], [900, 900, 50], [100, 900, 50], [900, 100, 50], [500, 100, 200], [500, 900, 200]]) == False\n assert candidate(xCorner = 6,yCorner = 8,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [1, 8, 1], [6, 1, 1]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[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]]) == False\n assert candidate(xCorner = 100,yCorner = 100,circles = [[25, 25, 20], [75, 75, 20], [50, 50, 20], [25, 75, 20], [75, 25, 20]]) == True\n assert candidate(xCorner = 9,yCorner = 9,circles = [[2, 2, 2], [2, 6, 2], [6, 2, 2], [6, 6, 2], [5, 5, 1]]) == False\n assert candidate(xCorner = 7,yCorner = 7,circles = [[2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1]]) == False\n assert candidate(xCorner = 1000000,yCorner = 1000000,circles = [[100000, 100000, 50000], [900000, 900000, 50000], [500000, 500000, 150000], [500000, 500000, 100000]]) == True\n assert candidate(xCorner = 7,yCorner = 7,circles = [[1, 6, 1], [2, 5, 1], [3, 4, 1], [4, 3, 1], [5, 2, 1], [6, 1, 1], [7, 7, 1], [7, 6, 1], [7, 5, 1], [7, 4, 1], [7, 3, 1], [7, 2, 1], [7, 1, 1]]) == False\n assert candidate(xCorner = 30,yCorner = 40,circles = [[15, 20, 5], [10, 25, 6], [20, 10, 4], [5, 30, 3], [25, 5, 2]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 30], [70, 70, 20], [30, 30, 25], [10, 10, 10], [90, 90, 10]]) == False\n assert candidate(xCorner = 12,yCorner = 12,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1], [11, 11, 1], [12, 12, 1], [1, 12, 1], [12, 1, 1]]) == False\n assert candidate(xCorner = 12,yCorner = 12,circles = [[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], [10, 10, 2], [11, 11, 2]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[5, 10, 3], [10, 5, 3], [10, 15, 3], [15, 10, 3], [10, 10, 5]]) == True\n assert candidate(xCorner = 8,yCorner = 8,circles = [[1, 8, 1], [8, 1, 1], [4, 4, 2], [2, 2, 1], [6, 6, 1], [5, 5, 1], [3, 3, 1], [7, 7, 1]]) == False\n assert candidate(xCorner = 10,yCorner = 3,circles = [[5, 2, 1], [4, 2, 1], [6, 2, 1], [3, 2, 1], [7, 2, 1], [2, 2, 1], [8, 2, 1], [5, 1, 1]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[1, 1, 1], [20, 20, 1], [10, 10, 5], [15, 5, 3]]) == False\n assert candidate(xCorner = 25,yCorner = 25,circles = [[5, 10, 5], [10, 5, 5], [20, 20, 5], [15, 15, 5], [25, 5, 5], [5, 25, 5]]) == False\n assert candidate(xCorner = 50,yCorner = 50,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [45, 45, 1], [46, 46, 1], [47, 47, 1], [48, 48, 1], [49, 49, 1]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 1, 1], [9, 9, 1], [5, 5, 2], [3, 3, 1], [7, 7, 1]]) == False\n assert candidate(xCorner = 15,yCorner = 15,circles = [[8, 8, 3], [7, 7, 2], [6, 6, 1], [9, 9, 2], [10, 10, 3], [11, 11, 4]]) == False\n assert candidate(xCorner = 50,yCorner = 50,circles = [[10, 10, 5], [20, 20, 5], [30, 30, 5], [40, 40, 5], [50, 50, 5]]) == False\n assert candidate(xCorner = 80,yCorner = 60,circles = [[10, 10, 10], [20, 20, 10], [30, 30, 10], [40, 40, 10], [50, 50, 10], [60, 60, 10], [70, 70, 10]]) == False\n assert candidate(xCorner = 10000,yCorner = 10000,circles = [[1000, 1000, 500], [9000, 9000, 500], [5000, 5000, 1500], [5000, 5000, 1000]]) == True\n assert candidate(xCorner = 7,yCorner = 7,circles = [[1, 1, 1], [1, 7, 1], [7, 1, 1], [7, 7, 1], [3, 4, 1], [4, 3, 1], [4, 5, 1], [5, 4, 1]]) == False\n assert candidate(xCorner = 9,yCorner = 9,circles = [[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]]) == False\n assert candidate(xCorner = 30,yCorner = 40,circles = [[10, 10, 5], [20, 20, 10], [5, 5, 2], [25, 25, 4]]) == True\n assert candidate(xCorner = 50,yCorner = 50,circles = [[25, 25, 10], [30, 30, 15], [20, 20, 5], [10, 40, 5]]) == True\n assert candidate(xCorner = 100000,yCorner = 100000,circles = [[10000, 10000, 5000], [90000, 90000, 5000], [50000, 50000, 15000], [50000, 50000, 10000]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 20], [30, 30, 5], [70, 70, 5], [10, 10, 2], [90, 90, 2], [10, 90, 2], [90, 10, 2], [50, 10, 10], [50, 90, 10]]) == True\n assert candidate(xCorner = 500000000,yCorner = 500000000,circles = [[250000000, 250000000, 100000000], [300000000, 300000000, 150000000]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[10, 10, 5], [90, 90, 5], [50, 50, 20], [50, 50, 10]]) == True\n assert candidate(xCorner = 1000,yCorner = 1000,circles = [[100, 100, 100], [900, 900, 100], [500, 500, 500], [300, 700, 200], [700, 300, 200]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 500000000], [1000000000, 1000000000, 1]]) == False\n assert candidate(xCorner = 1000,yCorner = 1000,circles = [[1, 1, 1], [1000, 1000, 1], [500, 500, 100], [900, 900, 50]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 499999999], [1000000000, 1000000000, 1]]) == False\n assert candidate(xCorner = 9,yCorner = 9,circles = [[3, 3, 2], [6, 6, 2], [4, 4, 1], [5, 5, 1]]) == True\n assert candidate(xCorner = 50,yCorner = 50,circles = [[25, 25, 10], [10, 10, 5], [40, 40, 5], [5, 5, 2], [45, 45, 2], [10, 40, 2], [40, 10, 2]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 10], [40, 40, 10], [60, 60, 10], [50, 30, 10], [50, 70, 10]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 1, 1], [9, 9, 1], [5, 5, 2], [2, 5, 1], [5, 2, 1]]) == False\n assert candidate(xCorner = 50,yCorner = 50,circles = [[10, 10, 5], [20, 20, 5], [30, 30, 5], [40, 40, 5]]) == True\n assert candidate(xCorner = 1000,yCorner = 1000,circles = [[100, 100, 100], [900, 900, 100], [500, 500, 300], [500, 500, 200]]) == False\n assert candidate(xCorner = 25,yCorner = 25,circles = [[5, 5, 4], [20, 20, 4], [15, 15, 4], [10, 10, 3], [25, 25, 1]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[5, 5, 4], [15, 15, 4], [10, 10, 6]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 10], [20, 20, 5], [80, 80, 5], [10, 10, 2], [90, 90, 2], [10, 90, 2], [90, 10, 2], [50, 10, 5], [50, 90, 5], [10, 50, 5], [90, 50, 5]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 1, 2], [9, 9, 2], [5, 5, 3]]) == False\n assert candidate(xCorner = 50,yCorner = 50,circles = [[10, 10, 5], [40, 40, 5], [10, 40, 5], [40, 10, 5], [25, 25, 10]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[2, 2, 2], [3, 3, 1], [4, 4, 2], [5, 5, 1], [6, 6, 2], [7, 7, 1], [8, 8, 2]]) == False\n assert candidate(xCorner = 100,yCorner = 50,circles = [[25, 25, 15], [75, 25, 15], [50, 45, 10]]) == True\n assert candidate(xCorner = 15,yCorner = 15,circles = [[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], [10, 10, 2], [11, 11, 2], [12, 12, 2], [13, 13, 2], [14, 14, 2]]) == False\n assert candidate(xCorner = 25,yCorner = 25,circles = [[5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1], [11, 11, 1], [12, 12, 1], [13, 13, 1], [14, 14, 1], [15, 15, 1], [16, 16, 1], [17, 17, 1], [18, 18, 1], [19, 19, 1], [20, 20, 1], [21, 21, 1], [22, 22, 1], [23, 23, 1], [24, 24, 1], [25, 25, 1], [1, 1, 12], [25, 25, 12]]) == False\n assert candidate(xCorner = 100,yCorner = 100,circles = [[25, 25, 20], [75, 75, 20], [50, 50, 10], [10, 90, 10], [90, 10, 10]]) == True\n assert candidate(xCorner = 999999999,yCorner = 999999999,circles = [[499999999, 499999999, 100000000], [500000000, 500000000, 200000000]]) == True\n assert candidate(xCorner = 999999999,yCorner = 999999999,circles = [[999999999, 999999999, 10], [1, 1, 100], [500000000, 500000000, 1000000]]) == False\n assert candidate(xCorner = 18,yCorner = 18,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1], [11, 11, 1], [12, 12, 1], [13, 13, 1], [14, 14, 1], [15, 15, 1], [16, 16, 1], [17, 17, 1], [18, 18, 1], [9, 9, 5]]) == False\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 20], [30, 70, 15], [70, 30, 15], [10, 10, 5], [90, 90, 5], [20, 20, 3], [80, 80, 3]]) == True\n assert candidate(xCorner = 12,yCorner = 12,circles = [[6, 6, 3], [3, 3, 2], [9, 9, 2], [1, 1, 1], [11, 11, 1]]) == False\n assert candidate(xCorner = 18,yCorner = 18,circles = [[9, 9, 5], [1, 1, 1], [17, 17, 1], [1, 17, 1], [17, 1, 1], [5, 5, 1], [13, 13, 1], [7, 13, 1], [13, 7, 1]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[5, 5, 3], [10, 10, 3], [15, 15, 3], [2, 2, 1], [18, 18, 1]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[3, 3, 2], [7, 7, 2], [5, 5, 1]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 40], [70, 30, 20], [30, 70, 25], [10, 10, 5], [90, 90, 5]]) == True\n assert candidate(xCorner = 20,yCorner = 20,circles = [[5, 5, 1], [15, 15, 1], [10, 10, 5], [5, 15, 1], [15, 5, 1]]) == True\n", "comparison": "exact"}, "public_tests": ["3\n4\n[[2,1,1]]", "3\n3\n[[1,1,2]]", "3\n3\n[[2,1,1],[1,2,1]]", "4\n4\n[[5,5,1]]"], "hints": ["Create a graph with n + 4 vertices.", "Vertices 0 to n - 1 represent the circles, vertex n represents upper edge, vertex n + 1 represents right edge, vertex n + 2 represents lower edge, and vertex n + 3 represents left edge.", "Add an edge between these vertices if they intersect or touch.", "Answer will be false when any of two sides left-right, left-bottom, right-top or top-bottom are reachable using the edges."], "metadata": {"canonical_parameter_names": ["xCorner", "yCorner", "circles"], "leetcode_dataset_entry_point": "Solution().canReachCorner", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T21:17:56+00:00", "tests_total": 105, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["array", "math", "depth-first-search", "breadth-first-search", "union-find", "geometry"]}, "language": "javascript", "interface": {"raw_signature": "var canReachCorner = function(xCorner, yCorner, circles) {", "container": null, "callable": "canReachCorner", "parameters": [{"name": "xCorner", "type": "number"}, {"name": "yCorner", "type": "number"}, {"name": "circles", "type": "number[][]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 3238, "task_id": "find-the-number-of-winning-players", "difficulty": "Easy", "problem_description": "You are given an integer n representing the number of players in a game and a 2D array pick where pick[i] = [x_i, y_i] represents that the player x_i picked a ball of color y_i.\n\nPlayer i wins the game if they pick strictly more than i balls of the same color. In other words,\n\n- Player 0 wins if they pick any ball.\n- Player 1 wins if they pick at least two balls of the same color.\n- ...\n- Player i wins if they pick at least i + 1 balls of the same color.\n\nReturn the number of players who win the game.\n\nNote that multiple players can win the game.\n\nExample 1:\n\nInput: n = 4, pick = [[0,0],[1,0],[1,0],[2,1],[2,1],[2,0]]\nOutput: 2\nExplanation:\nPlayer 0 and player 1 win the game, while players 2 and 3 do not win.\n\nExample 2:\n\nInput: n = 5, pick = [[1,1],[1,2],[1,3],[1,4]]\nOutput: 0\nExplanation:\nNo player wins the game.\n\nExample 3:\n\nInput: n = 5, pick = [[1,1],[2,4],[2,4],[2,4]]\nOutput: 1\nExplanation:\nPlayer 2 wins the game by picking 3 balls with color 4.\n\nConstraints:\n\n- 2 <= n <= 10\n- 1 <= pick.length <= 100\n- pick[i].length == 2\n- 0 <= x_i <= n - 1\n- 0 <= y_i <= 10\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,pick = [[0, 0], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3]]) == 4\n assert candidate(n = 10,pick = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 1\n assert candidate(n = 3,pick = [[0, 0], [1, 0], [1, 0], [1, 0]]) == 2\n assert candidate(n = 5,pick = [[1, 1], [2, 4], [2, 4], [2, 4]]) == 1\n assert candidate(n = 2,pick = [[0, 0], [1, 1], [1, 1]]) == 2\n assert candidate(n = 5,pick = [[1, 1], [1, 2], [1, 3], [1, 4]]) == 0\n assert candidate(n = 2,pick = [[0, 0], [1, 0], [1, 0], [1, 0]]) == 2\n assert candidate(n = 4,pick = [[0, 0], [1, 0], [1, 0], [2, 1], [2, 1], [2, 0]]) == 2\n assert candidate(n = 3,pick = [[0, 0], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2]]) == 3\n assert candidate(n = 4,pick = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]]) == 2\n assert candidate(n = 10,pick = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [0, 0], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4]]) == 5\n assert candidate(n = 4,pick = [[0, 1], [1, 1], [1, 2], [2, 2], [2, 2], [2, 2], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2]]) == 3\n assert candidate(n = 5,pick = [[0, 1], [1, 1], [1, 2], [2, 2], [2, 2], [2, 3], [2, 3], [3, 3], [3, 3], [3, 4], [3, 4], [4, 4], [4, 5], [4, 5], [4, 6]]) == 1\n assert candidate(n = 6,pick = [[0, 0], [1, 1], [1, 1], [1, 2], [2, 2], [2, 2], [2, 2], [2, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 6\n assert candidate(n = 10,pick = [[0, 0], [1, 0], [1, 0], [2, 0], [2, 0], [2, 0], [2, 1], [3, 0], [3, 1], [3, 2], [3, 2], [3, 2], [4, 0], [4, 1], [4, 2], [4, 3], [4, 3], [4, 3], [4, 3], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4], [5, 4], [5, 4], [6, 0], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 5], [6, 5], [7, 0], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 6], [7, 6], [8, 0], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 7], [8, 7], [9, 0], [9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 8], [9, 8]]) == 3\n assert candidate(n = 7,pick = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [4, 5], [5, 6], [5, 6], [5, 6], [5, 6], [6, 7], [6, 7], [6, 7], [6, 7], [6, 7], [6, 7], [6, 7]]) == 5\n assert candidate(n = 3,pick = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [2, 0], [2, 1], [2, 2], [2, 0], [2, 1], [2, 2], [2, 0], [2, 1], [2, 2]]) == 3\n assert candidate(n = 4,pick = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 1], [1, 2], [2, 1], [2, 2], [2, 2], [3, 1], [3, 2], [3, 3], [3, 3], [3, 3]]) == 2\n assert candidate(n = 6,pick = [[0, 0], [1, 0], [1, 0], [1, 1], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2], [3, 3], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]) == 2\n assert candidate(n = 7,pick = [[0, 0], [1, 0], [1, 1], [2, 1], [2, 2], [2, 2], [3, 2], [3, 3], [3, 3], [3, 3], [4, 3], [4, 4], [4, 4], [4, 4], [5, 4], [5, 4], [5, 5], [5, 5], [5, 5], [5, 5], [6, 5], [6, 5], [6, 5], [6, 6], [6, 6]]) == 1\n assert candidate(n = 3,pick = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]) == 2\n assert candidate(n = 5,pick = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 2\n assert candidate(n = 5,pick = [[0, 0], [0, 0], [0, 0], [0, 0], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [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]]) == 5\n assert candidate(n = 8,pick = [[0, 0], [0, 0], [0, 0], [1, 0], [1, 0], [1, 0], [1, 1], [1, 1], [2, 0], [2, 0], [2, 0], [2, 1], [2, 1], [2, 2], [2, 2], [3, 0], [3, 0], [3, 0], [3, 1], [3, 1], [3, 1], [3, 2], [3, 2], [3, 2], [3, 3], [3, 3], [4, 0], [4, 0], [4, 0], [4, 0], [4, 1], [4, 1], [4, 1], [4, 1], [4, 2], [4, 2], [4, 2], [4, 2], [4, 3], [4, 3], [4, 3], [4, 3], [4, 4], [4, 4], [4, 4]]) == 3\n assert candidate(n = 7,pick = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [4, 4], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6]]) == 2\n assert candidate(n = 5,pick = [[0, 0], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3]]) == 4\n assert candidate(n = 6,pick = [[0, 0], [1, 0], [1, 0], [1, 0], [2, 0], [2, 0], [2, 0], [2, 0], [3, 0], [3, 0], [3, 0], [3, 0], [3, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [5, 0], [5, 0], [5, 0], [5, 0], [5, 0], [5, 0]]) == 6\n assert candidate(n = 5,pick = [[0, 0], [0, 1], [1, 0], [1, 0], [1, 1], [2, 1], [2, 1], [2, 1], [3, 2], [3, 2], [3, 2], [3, 2]]) == 4\n assert candidate(n = 10,pick = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2]]) == 1\n assert candidate(n = 7,pick = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]) == 4\n assert candidate(n = 6,pick = [[0, 0], [0, 0], [1, 1], [1, 1], [1, 1], [1, 2], [1, 2], [2, 2], [2, 2], [2, 2], [2, 3], [2, 3], [2, 3], [3, 3], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 6\n assert candidate(n = 10,pick = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]]) == 1\n assert candidate(n = 5,pick = [[0, 0], [1, 0], [1, 1], [2, 1], [2, 2], [2, 2], [3, 2], [3, 2], [3, 3], [4, 3], [4, 4], [4, 4], [4, 4]]) == 1\n assert candidate(n = 4,pick = [[0, 0], [0, 0], [0, 0], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3]]) == 4\n assert candidate(n = 7,pick = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [0, 0], [1, 1], [2, 2]]) == 3\n assert candidate(n = 5,pick = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4]]) == 1\n assert candidate(n = 6,pick = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1]]) == 1\n assert candidate(n = 4,pick = [[0, 1], [0, 1], [0, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 1], [2, 1], [2, 1], [2, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1]]) == 4\n assert candidate(n = 8,pick = [[0, 0], [0, 0], [0, 0], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3]]) == 4\n assert candidate(n = 5,pick = [[0, 0], [1, 0], [1, 1], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2], [3, 3], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4]]) == 1\n assert candidate(n = 5,pick = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 4\n assert candidate(n = 5,pick = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 0], [1, 1], [1, 1], [1, 2], [1, 2], [2, 0], [2, 0], [2, 1], [2, 2], [3, 0], [3, 0], [3, 0], [4, 0]]) == 2\n assert candidate(n = 10,pick = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [9, 0], [9, 0], [9, 0], [9, 0]]) == 1\n assert candidate(n = 10,pick = [[0, 0], [0, 0], [0, 0], [1, 0], [1, 0], [1, 0], [1, 1], [1, 1], [2, 0], [2, 0], [2, 0], [2, 1], [2, 1], [2, 2], [2, 2], [3, 0], [3, 0], [3, 0], [3, 1], [3, 1], [3, 1], [3, 2], [3, 2], [3, 2], [3, 3], [3, 3], [4, 0], [4, 0], [4, 0], [4, 0], [4, 1], [4, 1], [4, 1], [4, 1], [4, 2], [4, 2], [4, 2], [4, 2], [4, 3], [4, 3], [4, 3], [4, 3], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [6, 6], [6, 6], [6, 6], [6, 6], [6, 6], [6, 6], [6, 6], [7, 7], [7, 7], [7, 7], [7, 7], [7, 7], [7, 7], [7, 7], [7, 7], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [9, 9], [9, 9], [9, 9], [9, 9], [9, 9], [9, 9], [9, 9], [9, 9], [9, 9], [9, 9]]) == 8\n assert candidate(n = 6,pick = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 5\n assert candidate(n = 6,pick = [[0, 1], [0, 1], [1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [4, 5], [4, 5], [5, 6]]) == 3\n assert candidate(n = 10,pick = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]]) == 1\n assert candidate(n = 5,pick = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [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]]) == 1\n assert candidate(n = 5,pick = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5]]) == 5\n assert candidate(n = 10,pick = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 4\n assert candidate(n = 4,pick = [[0, 0], [0, 1], [1, 0], [1, 1], [1, 0], [1, 1], [1, 0], [1, 1], [1, 0], [1, 1], [2, 0], [2, 0], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [3, 0], [3, 1], [3, 2], [3, 0], [3, 1], [3, 2], [3, 0], [3, 1], [3, 2], [3, 0], [3, 1], [3, 2]]) == 4\n assert candidate(n = 5,pick = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 5\n assert candidate(n = 10,pick = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 3\n assert candidate(n = 6,pick = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 1], [0, 1], [1, 2], [1, 2], [2, 3], [2, 3], [3, 4], [3, 4], [4, 5], [4, 5], [5, 6], [5, 6], [0, 1], [0, 1], [0, 1], [1, 2], [1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [5, 6], [5, 6], [5, 6], [5, 6], [5, 6], [5, 6], [5, 6]]) == 6\n assert candidate(n = 4,pick = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 1], [1, 2], [2, 3], [3, 4], [0, 1], [1, 2]]) == 2\n assert candidate(n = 7,pick = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [3, 1], [4, 1], [5, 1], [6, 1], [4, 1], [5, 1], [6, 1], [5, 1], [6, 1], [6, 1]]) == 7\n assert candidate(n = 9,pick = [[0, 0], [1, 0], [1, 1], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2], [3, 3], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [6, 0], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [7, 0], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [8, 0], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8]]) == 1\n assert candidate(n = 6,pick = [[0, 0], [0, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4]]) == 5\n assert candidate(n = 5,pick = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 1], [1, 2], [1, 3], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [4, 0]]) == 1\n assert candidate(n = 5,pick = [[0, 0], [1, 1], [1, 2], [2, 2], [2, 3], [3, 3], [3, 3], [3, 4], [4, 0], [4, 1], [4, 1]]) == 1\n assert candidate(n = 10,pick = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [0, 1], [0, 1], [1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4]]) == 4\n assert candidate(n = 5,pick = [[0, 0], [1, 0], [1, 1], [2, 1], [2, 2], [2, 2], [3, 2], [3, 3], [3, 3], [3, 3]]) == 1\n assert candidate(n = 5,pick = [[0, 1], [1, 1], [1, 2], [2, 2], [2, 3], [2, 3], [3, 3], [3, 4], [3, 4], [3, 4], [4, 4]]) == 1\n assert candidate(n = 10,pick = [[0, 0], [1, 0], [1, 1], [2, 1], [2, 2], [2, 2], [3, 2], [3, 3], [3, 3], [3, 3], [4, 3], [4, 4], [4, 4], [4, 4], [5, 4], [5, 4], [5, 5], [5, 5], [5, 5], [5, 5], [6, 5], [6, 5], [6, 5], [6, 6], [6, 6], [7, 6], [7, 6], [7, 6], [7, 6], [7, 7], [8, 7], [8, 7], [8, 7], [8, 7], [8, 8], [8, 8], [9, 8], [9, 8], [9, 8], [9, 8], [9, 9], [9, 9], [9, 9], [9, 9]]) == 1\n assert candidate(n = 6,pick = [[0, 0], [0, 0], [0, 0], [0, 0], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 4\n assert candidate(n = 6,pick = [[0, 0], [1, 0], [1, 1], [2, 1], [2, 2], [2, 2], [3, 2], [3, 3], [3, 3], [3, 3], [4, 3], [4, 4], [4, 4], [4, 4], [5, 4], [5, 4], [5, 5], [5, 5], [5, 5], [5, 5]]) == 1\n assert candidate(n = 5,pick = [[0, 1], [1, 1], [1, 1], [1, 1], [1, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3]]) == 3\n assert candidate(n = 7,pick = [[0, 0], [1, 0], [1, 1], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2], [3, 3], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [6, 0], [6, 0], [6, 1], [6, 1], [6, 2], [6, 2], [6, 3], [6, 3], [6, 4], [6, 4], [6, 5], [6, 5]]) == 1\n assert candidate(n = 5,pick = [[0, 0], [1, 0], [1, 0], [1, 0], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3]]) == 5\n", "comparison": "exact"}, "public_tests": ["4\n[[0,0],[1,0],[1,0],[2,1],[2,1],[2,0]]", "5\n[[1,1],[1,2],[1,3],[1,4]]", "5\n[[1,1],[2,4],[2,4],[2,4]]"], "hints": ["Keep track of the number of balls of each color for each user using hashing.", "Find the maximum color that occurred for each player."], "metadata": {"canonical_parameter_names": ["n", "pick"], "leetcode_dataset_entry_point": "Solution().winningPlayerCount", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T21:18:02+00:00", "tests_total": 69, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "counting"]}, "language": "javascript", "interface": {"raw_signature": "var winningPlayerCount = function(n, pick) {", "container": null, "callable": "winningPlayerCount", "parameters": [{"name": "n", "type": "number"}, {"name": "pick", "type": "number[][]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 3239, "task_id": "minimum-number-of-flips-to-make-binary-grid-palindromic-i", "difficulty": "Medium", "problem_description": "You are given an m x n binary matrix grid.\n\nA row or column is considered palindromic if its values read the same forward and backward.\n\nYou can flip any number of cells in grid from 0 to 1, or from 1 to 0.\n\nReturn the minimum number of cells that need to be flipped to make either all rows palindromic or all columns palindromic.\n\nExample 1:\n\nInput: grid = [[1,0,0],[0,0,0],[0,0,1]]\nOutput: 2\nExplanation:\nFlipping the highlighted cells makes all the rows palindromic.\n\nExample 2:\n\nInput: grid = [[0,1],[0,1],[0,0]]\nOutput: 1\nExplanation:\nFlipping the highlighted cell makes all the columns palindromic.\n\nExample 3:\n\nInput: grid = [[1],[0]]\nOutput: 0\nExplanation:\nAll rows are already palindromic.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m * n <= 2 * 10^5\n- 0 <= grid[i][j] <= 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 0, 1, 1], [1, 1, 0, 0], [1, 0, 1, 0]]) == 2\n assert candidate(grid = [[1], [0]]) == 0\n assert candidate(grid = [[0, 1], [0, 1], [0, 0]]) == 1\n assert candidate(grid = [[1, 1, 0], [0, 1, 0], [0, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 1], [1, 0, 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\n assert candidate(grid = [[1, 0, 0], [0, 0, 0], [0, 0, 1]]) == 2\n assert candidate(grid = [[0, 0, 1, 1], [1, 1, 0, 0], [1, 1, 0, 0]]) == 4\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 1, 0, 0], [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, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 1, 1], [1, 0, 1, 0, 0], [0, 0, 1, 1, 1]]) == 6\n assert candidate(grid = [[0, 0, 0, 1, 0, 1], [1, 1, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 2\n assert candidate(grid = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 0, 0, 0, 1, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 0], [0, 1, 1, 0, 1], [1, 0, 0, 1, 1], [0, 1, 1, 0, 1]]) == 6\n assert candidate(grid = [[0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0]]) == 4\n assert candidate(grid = [[1, 1, 1, 0, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 0, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1]]) == 2\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 1, 0, 1, 1], [1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0]]) == 6\n assert candidate(grid = [[0, 1, 1, 0, 0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0, 0, 1, 1, 0]]) == 20\n assert candidate(grid = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 12\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 1, 0, 0, 1, 1], [0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 8\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 24\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 12\n assert candidate(grid = [[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]]) == 16\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[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], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0]]) == 12\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\n assert candidate(grid = [[0, 1, 1, 1, 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, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0]]) == 0\n assert candidate(grid = [[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, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0]]) == 4\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 1, 0], [1, 0, 0, 1], [0, 1, 1, 0], [1, 0, 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, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 1, 0, 1], [1, 1, 0, 0, 1, 1], [0, 1, 0, 1, 0, 1]]) == 3\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1]]) == 16\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 6\n assert candidate(grid = [[1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0], [1, 0, 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]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 1, 0, 0, 1, 0, 0, 1, 0], [1, 0, 1, 0, 0, 1, 0, 1, 1], [0, 1, 0, 1, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 7\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\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 9\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0]]) == 4\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]]) == 0\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, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0], [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1], [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0], [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]]) == 16\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]]) == 20\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]]) == 3\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\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 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]]) == 20\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 1, 1, 1, 1, 0, 1], [0, 0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0], [1, 1, 0, 1, 1, 1, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1, 0, 0, 1], [0, 1, 0, 0, 1, 0, 0, 1, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 2\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]]) == 16\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 1, 0, 1, 0, 1, 0, 0], [1, 0, 0, 1, 0, 1, 0, 0, 1], [0, 1, 0, 0, 1, 0, 0, 1, 0], [1, 0, 1, 0, 0, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]) == 3\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]) == 0\n", "comparison": "exact"}, "public_tests": ["[[1,0,0],[0,0,0],[0,0,1]]", "[[0,1],[0,1],[0,0]]", "[[1],[0]]"], "hints": ["We need to perform the operation only when the equivalent element of i from the back is not equal."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minFlips", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T21:18:05+00:00", "tests_total": 77, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "two-pointers", "matrix"]}, "language": "javascript", "interface": {"raw_signature": "var minFlips = function(grid) {", "container": null, "callable": "minFlips", "parameters": [{"name": "grid", "type": "number[][]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 3240, "task_id": "minimum-number-of-flips-to-make-binary-grid-palindromic-ii", "difficulty": "Medium", "problem_description": "You are given an m x n binary matrix grid.\n\nA row or column is considered palindromic if its values read the same forward and backward.\n\nYou can flip any number of cells in grid from 0 to 1, or from 1 to 0.\n\nReturn the minimum number of cells that need to be flipped to make all rows and columns palindromic, and the total number of 1's in grid divisible by 4.\n\nExample 1:\n\nInput: grid = [[1,0,0],[0,1,0],[0,0,1]]\nOutput: 3\nExplanation:\n\nExample 2:\n\nInput: grid = [[0,1],[0,1],[0,0]]\nOutput: 2\nExplanation:\n\nExample 3:\n\nInput: grid = [[1],[1]]\nOutput: 2\nExplanation:\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m * n <= 2 * 10^5\n- 0 <= grid[i][j] <= 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == 3\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 1\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 1\n assert candidate(grid = [[0, 1], [0, 1], [0, 0]]) == 2\n assert candidate(grid = [[0, 1, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 0, 0, 1], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0]]) == 6\n assert candidate(grid = [[1], [1]]) == 2\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]]) == 0\n assert candidate(grid = [[1, 0], [0, 1], [1, 0]]) == 3\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1]]) == 8\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 8\n assert candidate(grid = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 6\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 0], [1, 0, 1], [0, 1, 0]]) == 0\n assert candidate(grid = [[1, 0], [0, 1], [1, 0], [0, 1]]) == 4\n assert candidate(grid = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 1, 0]]) == 2\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1], [0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1], [0, 1, 0, 0, 1, 0, 0], [1, 0, 0, 1, 0, 0, 1]]) == 7\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [1, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 0, 1], [0, 1, 0, 1, 1, 0]]) == 12\n assert candidate(grid = [[1, 1, 0, 1], [0, 0, 0, 0], [1, 0, 0, 1], [1, 1, 1, 1]]) == 3\n assert candidate(grid = [[1, 1, 0, 1], [1, 1, 0, 1], [0, 0, 1, 0], [0, 0, 1, 0], [1, 1, 0, 1], [1, 1, 0, 1]]) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 0, 1, 1, 0, 1], [0, 1, 0, 0, 1, 0], [1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0], [1, 0, 0, 1, 0, 1]]) == 6\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1], [0, 1, 0]]) == 6\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 10\n assert candidate(grid = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1]]) == 8\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 14\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]]) == 18\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0]]) == 12\n assert candidate(grid = [[1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 0, 1]]) == 6\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1], [0, 1, 1, 1, 0]]) == 8\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0, 1], [1, 1, 0, 0, 0, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0, 1]]) == 15\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 12\n assert candidate(grid = [[1, 0, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1]]) == 12\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\n assert candidate(grid = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 1, 0, 1, 0, 1], [0, 1, 0, 0, 1, 0, 1, 0], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [0, 1, 0, 0, 1, 0, 1, 0], [1, 0, 1, 1, 0, 1, 0, 1]]) == 4\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 1, 0], [1, 0, 1, 1, 1, 1, 0, 1], [1, 1, 0, 1, 1, 0, 1, 1], [1, 1, 1, 0, 0, 1, 1, 1], [1, 1, 0, 1, 1, 0, 1, 1], [1, 0, 1, 1, 1, 1, 0, 1], [0, 1, 1, 1, 1, 1, 1, 0]]) == 2\n assert candidate(grid = [[1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 1, 0, 0, 1]]) == 4\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 15\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 8\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1]]) == 12\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == 10\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 0, 0, 1, 0], [0, 0, 0, 1, 1, 0, 1], [1, 1, 1, 0, 0, 1, 0], [0, 0, 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]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1]]) == 16\n assert candidate(grid = [[1, 0, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 1]]) == 4\n assert candidate(grid = [[1, 1, 0, 0, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 0, 0, 1]]) == 3\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 1, 0, 0]]) == 7\n assert candidate(grid = [[1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 1, 0, 0, 1, 0], [1, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0]]) == 18\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 1, 0, 1], [1, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1]]) == 10\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\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]]) == 20\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 1], [0, 0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 1, 1, 1, 0], [1, 0, 0, 1, 0, 0, 1], [0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 1]]) == 7\n assert candidate(grid = [[0, 0, 1, 1, 0, 0], [0, 1, 1, 1, 1, 0], [1, 1, 0, 0, 1, 1], [0, 1, 1, 1, 1, 0], [0, 0, 1, 1, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0], [1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0]]) == 14\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 14\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 10\n assert candidate(grid = [[0, 0, 1, 0, 1, 0], [1, 0, 1, 1, 0, 1], [0, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0]]) == 8\n assert candidate(grid = [[1, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 35\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]]) == 50\n assert candidate(grid = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 9\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 1, 1, 0]]) == 9\n assert candidate(grid = [[1, 1, 0, 1, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 1, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 1, 1, 0, 1, 1]]) == 10\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]]) == 1\n assert candidate(grid = [[1, 0, 1, 1, 0], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 0, 1, 1, 0]]) == 5\n assert candidate(grid = [[0, 1, 0, 0, 1, 0], [1, 0, 1, 1, 0, 1], [0, 1, 0, 0, 1, 0], [1, 0, 1, 1, 0, 1]]) == 12\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]) == 12\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 14\n assert candidate(grid = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 10\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 0, 1, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 1, 0, 0, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[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, 1], [0, 0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0, 0], [1, 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]]) == 4\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 22\n assert candidate(grid = [[1, 0, 1, 1, 0, 1], [0, 1, 0, 0, 1, 0], [1, 0, 1, 1, 0, 1], [0, 1, 0, 0, 1, 0], [1, 0, 1, 1, 0, 1]]) == 0\n", "comparison": "exact"}, "public_tests": ["[[1,0,0],[0,1,0],[0,0,1]]", "[[0,1],[0,1],[0,0]]", "[[1],[1]]"], "hints": ["For each (x, y), find (m - 1 - x, y), (m - 1 - x, n - 1 - y), and (x, n - 1 - y); they should be the same.", "Note that we need to specially handle the middle row (column) if the number of rows (columns) is odd."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minFlips", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T21:18:07+00:00", "tests_total": 88, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "two-pointers", "matrix"]}, "language": "javascript", "interface": {"raw_signature": "var minFlips = function(grid) {", "container": null, "callable": "minFlips", "parameters": [{"name": "grid", "type": "number[][]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}