diff --git "a/data/train/java-001.jsonl" "b/data/train/java-001.jsonl" --- "a/data/train/java-001.jsonl" +++ "b/data/train/java-001.jsonl" @@ -22,7 +22,7 @@ {"question_id": 809, "task_id": "expressive-words", "difficulty": "Medium", "problem_description": "Sometimes people repeat letters to represent extra feeling. For example:\n\n- \"hello\" -> \"heeellooo\"\n- \"hi\" -> \"hiiii\"\n\nIn these strings like \"heeellooo\", we have groups of adjacent letters that are all the same: \"h\", \"eee\", \"ll\", \"ooo\".\n\nYou are given a string s and an array of query strings words. A query word is stretchy if it can be made to be equal to s by any number of applications of the following extension operation: choose a group consisting of characters c, and add some number of characters c to the group so that the size of the group is three or more.\n\n- For example, starting with \"hello\", we could do an extension on the group \"o\" to get \"hellooo\", but we cannot get \"helloo\" since the group \"oo\" has a size less than three. Also, we could do another extension like \"ll\" -> \"lllll\" to get \"helllllooo\". If s = \"helllllooo\", then the query word \"hello\" would be stretchy because of these two extension operations: query = \"hello\" -> \"hellooo\" -> \"helllllooo\" = s.\n\nReturn the number of query strings that are stretchy.\n\nExample 1:\n\nInput: s = \"heeellooo\", words = [\"hello\", \"hi\", \"helo\"]\nOutput: 1\nExplanation:\nWe can extend \"e\" and \"o\" in the word \"hello\" to get \"heeellooo\".\nWe can't extend \"helo\" to get \"heeellooo\" because the group \"ll\" is not size 3 or more.\n\nExample 2:\n\nInput: s = \"zzzzzyyyyy\", words = [\"zzyy\",\"zy\",\"zyy\"]\nOutput: 3\n\nConstraints:\n\n- 1 <= s.length, words.length <= 100\n- 1 <= words[i].length <= 100\n- s and words[i] consist of lowercase letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaabaaa\",words = ['aa', 'aaa', 'aaaa', 'aabaaa']) == 1\n assert candidate(s = \"aaabaaa\",words = ['aaa', 'aab', 'aaaaa', 'aaabaa', 'aaaba']) == 2\n assert candidate(s = \"abcd\",words = ['abc', 'abcd', 'abdc', 'aabbccdd']) == 1\n assert candidate(s = \"abcd\",words = ['abc', 'abcd', 'abcde']) == 1\n assert candidate(s = \"aaabbbcccddd\",words = ['aabbccddd', 'aabbbcccddd', 'aabbbcccdd']) == 3\n assert candidate(s = \"a\",words = ['a', 'aa', 'aaa', 'aaaa']) == 1\n assert candidate(s = \"aabbcc\",words = ['aabbcc', 'aabbc', 'aaabc']) == 1\n assert candidate(s = \"abcd\",words = ['aabbccdd', 'abccdd', 'abbbccdd', 'aabbcccddd']) == 0\n assert candidate(s = \"heeellooo\",words = ['hello', 'hi', 'helo']) == 1\n assert candidate(s = \"aaabaaa\",words = ['aab', 'aaab', 'aaaab', 'aaaba', 'aaaaaaab']) == 1\n assert candidate(s = \"abcd\",words = ['abc', 'ab', 'abcd', 'abcde']) == 1\n assert candidate(s = \"aaa\",words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa']) == 3\n assert candidate(s = \"abcd\",words = ['abc', 'abcd', 'abcde', 'ab', 'a']) == 1\n assert candidate(s = \"aaabbb\",words = ['aabb', 'aabbbb', 'aaabbbb']) == 1\n assert candidate(s = \"abcd\",words = ['abc', 'ab', 'abcd', 'abcde', 'aabbccdd']) == 1\n assert candidate(s = \"zzzzzyyyyy\",words = ['zzyy', 'zy', 'zyy']) == 3\n assert candidate(s = \"heeellloooopppp\",words = ['helloppp', 'heellooppp', 'helooppp', 'helllopppp', 'heeelllooooooo', 'hello']) == 4\n assert candidate(s = \"ttttuuuuuuuuuuuuvvv\",words = ['tuv', 'tttuuuuuuuuuuvvv', 'ttttuuuuuuuuuuu', 'ttttuuuuuuuuuvv', 'ttttuuuuuuuuuuuuv']) == 4\n assert candidate(s = \"heeeloooooo\",words = ['hello', 'heeellooo', 'helllooo', 'heellooo', 'heeelloo']) == 0\n assert candidate(s = \"aaaabbbbcccc\",words = ['aabbcc', 'aaabbbcccc', 'aaaabbbbccc', 'aaaabbbcccc', 'aaaaabbbbcccc']) == 4\n assert candidate(s = \"aaaabbbbccccddddeeee\",words = ['aabcd', 'abbbcd', 'abccde', 'abcde', 'aaaaabbbbccccddddeee']) == 2\n assert candidate(s = \"mmmmnnnnnnoooopppppp\",words = ['mnop', 'mmnnnnoooppp', 'mmmmmnnnnnnnoooooopppppp', 'mmnnoopp', 'mmnnoooopppp']) == 4\n assert candidate(s = \"xxxxxyyyyyyzzzzzz\",words = ['xyzz', 'xxxyyyyzzz', 'xxxxxyyyzzzzz', 'xxxxxyyyyyyzzzz', 'xxxxxyyyyyyzzzzzz']) == 5\n assert candidate(s = \"llllaaaabbbbccccddddeeeee\",words = ['laabcd', 'labbbccddeee', 'labcde', 'laaaabbbbccccddddeee', 'lbbbcccddddeeee']) == 3\n assert candidate(s = \"abbbcccddd\",words = ['abc', 'abbc', 'abbcc', 'abbbcccd', 'abbbcccddd', 'abbbcccdd', 'abbbccccd', 'abbbccccdd']) == 3\n assert candidate(s = \"mmmmnnnnoooopppp\",words = ['mno', 'mmnnnnooooppp', 'mmmmnnnnoooop', 'mmmmnnnnoooopppp', 'mmmmnnnnoooppp']) == 4\n assert candidate(s = \"heeellloooowooorlddd\",words = ['helo', 'hello', 'helooworld', 'heeellooworld', 'heeelllooooowooorlddd']) == 2\n assert candidate(s = \"mmmmmmmnnnnnnn\",words = ['mmnn', 'mmmnnn', 'mmmmnnnn', 'mmmmmn', 'mmmmnn', 'mmmmmnnn', 'mmmmmmnnnnn', 'mmmmmmnnnn']) == 8\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",words = ['abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'zzzzz', 'aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz', 'aabbbccddeeefffgghhhiiiijjjkkklllmmmnnnooooppppqqqqrrrrsssss', 'aabbccddeeefffgggiiiijjjkkklllmmmnnnoooopppqqqqrrrrrrsssss', 'aabbccddeeffgghhiijjkkklllmmmmmnnnnnoooooopppppqqqqqqrrrrrrssssss']) == 1\n assert candidate(s = \"xyzzzzzyyyyyyyy\",words = ['xyz', 'xyyz', 'xyzz', 'xyzzz', 'xyzzzz', 'xyzzzzzyyyyy', 'xyzzzzzyyyyyy', 'xyzzzzzyyyyyyyy']) == 3\n assert candidate(s = \"zzzzzzzyyyyyyy\",words = ['zzzyyyy', 'zzzzzyyy', 'zzzyyyyyyy', 'zzzzzzzzyy', 'zyyyyyyy']) == 4\n assert candidate(s = \"mississippiiii\",words = ['mississippi', 'missisiiippi', 'mississippiiiii', 'missisipi', 'misisipi']) == 1\n assert candidate(s = \"xxyyzzzz\",words = ['xxyyz', 'xxyyzz', 'xxxyyyzzzz', 'xxyyzzz', 'xyzzz']) == 3\n assert candidate(s = \"aabbccccddddeeeffggg\",words = ['aabbccddeeffg', 'aabbcccddddeffgg', 'aabbbccccddddeeeffggg', 'aabbbcccddddeeeffgg', 'aabbccccdddddeeeffggg']) == 2\n assert candidate(s = \"xxxxxxyyyyyyzzzzzz\",words = ['xyzz', 'xyzzz', 'xyyz', 'xxxyyyyzzz', 'xxxxxyyyyyyzzzzzz']) == 5\n assert candidate(s = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",words = ['qq', 'qqq', 'qqqq', 'qqqqqq', 'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq']) == 4\n assert candidate(s = \"ttttttttttttuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvvvvvvv\",words = ['tuv', 'ttuuuvvv', 'ttttuuuuuuuvvvvvvv', 'tttuuuuuuvvvvvvvvvv', 'ttttuuuuuuuuuuuvvvvvvvvvvvvvvvvvv']) == 5\n assert candidate(s = \"ppppqqqqrrrrssss\",words = ['pqrst', 'pqrs', 'ppqrs', 'ppqqrrss', 'ppqqqrrrssss', 'ppqqqqrrrrsssss']) == 4\n assert candidate(s = \"helloooooworlddddd\",words = ['hellooworld', 'hellooworlddd', 'hellllooworld', 'helloooworldddddd', 'hellooooooworlddddd']) == 2\n assert candidate(s = \"mississippiissi\",words = ['mississippissi', 'misisipi', 'mississippi', 'mississsippi', 'mississippiii']) == 0\n assert candidate(s = \"aabbccddeee\",words = ['abcde', 'aabbcdeee', 'aaabbbcccdddeee', 'aabbccdde', 'aabccdeee']) == 1\n assert candidate(s = \"ppppqqqqrrrssss\",words = ['pqr', 'ppqqrrsss', 'pppqqqrrrrssss', 'ppqqrrsssss', 'ppqqrrr']) == 1\n assert candidate(s = \"abcdefghijklllllmnopqrstuvwxyz\",words = ['abcdefghijklmopqrstuvwxyz', 'abcdefghijklllmmnopqrstuvwxyz', 'abcdefghijkllllmnopqrstuvwxyz', 'abcdefghijklllllmnopqrstuvwxy', 'abcdefghijklllllmnopqrstuvwxyz']) == 2\n assert candidate(s = \"hhheeelllllooooworrlldd\",words = ['helloworld', 'hhhellooooworld', 'hheeellllllooooworld', 'hellooworld', 'hheellooworl']) == 0\n assert candidate(s = \"ssssaaafffff\",words = ['saff', 'ssaff', 'ssaaaff', 'ssaaaafff', 'ssaaaaaffff', 'ssssaaaafffff']) == 3\n assert candidate(s = \"abcdefghijjjjjjjklmnopqrstuvwxyz\",words = ['abcdefghijklnopqrstuvwxyz', 'abcdefghijjjklmnopqrstuvwxyz', 'abcdefghijjjjjjklmnopqrstuvwxyz', 'abcdefghijjjjjjjklmnopqrstuv', 'abcdefghijjjjjjjmnopqrstuvwxyz']) == 2\n assert candidate(s = \"abcdefghiiiiijjjjjjkkkkkkk\",words = ['abcdefghijjk', 'abcdefghijk', 'abcdefghiiijjjjkk', 'abcdefghiiijjjjjjkkkkk', 'abcdefghiiijjjjjjkkkkkkk']) == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",words = ['abcdefghijklmnopqrstuvwxyzz', 'abcdefghijklmnopqrstuvwxy', 'abcdefghijklmnopqrstuvwxyzzz', 'abcdefghijklmnopqrstuvwxyzzzz', 'abcdefghijklmnopqrstuvwxyzzzzz']) == 0\n assert candidate(s = \"aaaaaaabbbbcccdd\",words = ['aabbbccdd', 'aaabbbcccdd', 'aaaabbbcccdd', 'aaaaabbbcccdd', 'aaaaaaabbbcccdd', 'aaaaaaabbbcccd', 'aaaaaaabbbbccdd', 'aaaaaaabbbbcccdd']) == 7\n assert candidate(s = \"qqqqqqqqqqqwwweeeerrrrttttt\",words = ['qqqqqqqwwwreeeeeerttt', 'qqqwwwreeert', 'qqqqqqqwwwreeerrttt', 'qqqqqqqqqqqwwweeeerrrtttt', 'qqqqqqqwwweeeerrrtttt']) == 2\n assert candidate(s = \"abcdeeeeef\",words = ['abcdeeef', 'abcdeeeef', 'abcdeeeeeef', 'abcdfeeeef', 'abcdef']) == 3\n assert candidate(s = \"abbbccdddd\",words = ['abcdd', 'abbbccdd', 'abbbccccdd', 'abbbccdddd', 'aabbccddd']) == 2\n assert candidate(s = \"ppppqqqqrrr\",words = ['pqr', 'pppqqrr', 'ppqqqrrr', 'pppqqqqrrr', 'ppppqqqrrr']) == 5\n assert candidate(s = \"aaaaaabbcccddeeeee\",words = ['aabccddee', 'aaabbbcccdddeeee', 'aaaabbbcccdddeee', 'aaaaabbcccddeeee', 'aaaaabbbbccccddeeeeee']) == 1\n assert candidate(s = \"llllllmmmnnnnoo\",words = ['lmno', 'lllmmnno', 'lllllmmnnnoo', 'lllmmmnnnnoo', 'llllllmmmnnno']) == 2\n assert candidate(s = \"aabbccddeeefffggg\",words = ['aabbccddeefffggg', 'aabbbcccdddeeefffggg', 'aabbccddeeeffffgggg', 'aabbccddeeeffg', 'aabbcddfeeeffggg']) == 2\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",words = ['z', 'zz', 'zzz', 'zzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz']) == 4\n assert candidate(s = \"ttrrreeee\",words = ['tree', 'ttrree', 'ttrreee', 'ttreee', 'ttrre', 'ttre', 'trreee', 'ttreere']) == 5\n assert candidate(s = \"mmmaaa\",words = ['maa', 'maaaa', 'mmmaaa', 'mmma', 'mmmaaaam']) == 3\n assert candidate(s = \"sssssssssssssssssssssssssssss\",words = ['s', 'ss', 'sss', 'sssss', 'sssssss', 'sssssssssssssssssssssssssssss']) == 6\n assert candidate(s = \"nnnnooouuuuuuuuu\",words = ['no', 'noon', 'nou', 'noou', 'noonnouuuu', 'nnoooouuuuuuuu', 'nnooouuuuuuuuu', 'nnnooouuuuuuuuu']) == 4\n assert candidate(s = \"aaabbbccc\",words = ['aabbccc', 'aaabccc', 'aaabbbcc', 'aabbbccc', 'aaabbbccccc']) == 4\n assert candidate(s = \"aaabbbcccddd\",words = ['ab', 'aabbccddd', 'aabbbcccddd', 'aaabbbcccdd', 'aaabbbcccd']) == 4\n assert candidate(s = \"aaaabbbbccccdddd\",words = ['aabbccdd', 'aaabbbcccddd', 'aaaabbbbccccdddd', 'aabbbbccccdddd', 'aaaabbbcccdddd']) == 5\n assert candidate(s = \"qqqqqqqqqqqqqqqqq\",words = ['q', 'qq', 'qqq', 'qqqq', 'qqqqq', 'qqqqqq', 'qqqqqqqq', 'qqqqqqqqqqqqqqqqq']) == 8\n assert candidate(s = \"xxxyyyzzz\",words = ['xyzz', 'xxyyz', 'xxyyzz', 'xxxyyyzzz', 'xxxyyzzz', 'xxxxyyzzz', 'xxxyyyyzzz']) == 5\n assert candidate(s = \"abbbbbccccdddd\",words = ['abc', 'abcd', 'abbc', 'abcdd', 'abbbbbccccdddd']) == 3\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccccccc\",words = ['aabbbccc', 'aaaaaaaaabbbbbbbbbbcccccccc', 'aaaaaaaaabbbbbbbbcccccccccc', 'aaaaaaaaaabbbbbbbbbbcccccc', 'aaaaaaaaaabbbbbbbbbbccccccccccc']) == 4\n assert candidate(s = \"mississiissippii\",words = ['mississippi', 'mississiippii', 'mississsippii', 'mississssippiii', 'mississssiiiiippiii']) == 0\n assert candidate(s = \"xyzzzzzzzzzxyzzzzzzzzzxyzzzzzzzzz\",words = ['xyzyxzy', 'xyzzzxyzzzxyzzz', 'xyzzzzxyzzzzxyzzzz', 'xyzzzzzzzzxyzzzzzzzzxyzzzzzzzz', 'xyzzzzzzzzzxyzzzzzzzzxzzzzzzzzzz']) == 3\n", "comparison": "exact"}, "public_tests": ["\"heeellooo\"\n[\"hello\", \"hi\", \"helo\"]", "\"zzzzzyyyyy\"\n[\"zzyy\",\"zy\",\"zyy\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["s", "words"], "leetcode_dataset_entry_point": "Solution().expressiveWords", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:26+00:00", "tests_total": 71, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "two-pointers", "string"]}, "language": "java", "interface": {"raw_signature": "public int expressiveWords(String s, String[] words) {", "container": "Solution", "callable": "expressiveWords", "parameters": [{"name": "s", "type": "String"}, {"name": "words", "type": "String[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 810, "task_id": "chalkboard-xor-game", "difficulty": "Hard", "problem_description": "You are given an array of integers nums represents the numbers written on a chalkboard.\n\nAlice and Bob take turns erasing exactly one number from the chalkboard, with Alice starting first. If erasing a number causes the bitwise XOR of all the elements of the chalkboard to become 0, then that player loses. The bitwise XOR of one element is that element itself, and the bitwise XOR of no elements is 0.\n\nAlso, if any player starts their turn with the bitwise XOR of all the elements of the chalkboard equal to 0, then that player wins.\n\nReturn true if and only if Alice wins the game, assuming both players play optimally.\n\nExample 1:\n\nInput: nums = [1,1,2]\nOutput: false\nExplanation:\nAlice has two choices: erase 1 or erase 2.\nIf she erases 1, the nums array becomes [1, 2]. The bitwise XOR of all the elements of the chalkboard is 1 XOR 2 = 3. Now Bob can remove any element he wants, because Alice will be the one to erase the last element and she will lose.\nIf Alice erases 2 first, now nums become [1, 1]. The bitwise XOR of all the elements of the chalkboard is 1 XOR 1 = 0. Alice will lose.\n\nExample 2:\n\nInput: nums = [0,1]\nOutput: true\n\nExample 3:\n\nInput: nums = [1,2,3]\nOutput: true\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- 0 <= nums[i] < 2^16\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 2, 3]) == True\n assert candidate(nums = [1, 1, 1, 1]) == True\n assert candidate(nums = [8, 15, 23, 42, 67]) == False\n assert candidate(nums = [1, 2, 2, 1]) == True\n assert candidate(nums = [1, 3, 5, 7, 9]) == False\n assert candidate(nums = [1, 2, 2, 3, 3, 4]) == True\n assert candidate(nums = [1]) == False\n assert candidate(nums = [5, 7, 9, 11]) == True\n assert candidate(nums = [0, 1]) == True\n assert candidate(nums = [4, 5, 6, 7, 8]) == False\n assert candidate(nums = [1, 1, 2]) == False\n assert candidate(nums = [2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [1, 1, 1, 1, 1]) == False\n assert candidate(nums = [1, 0, 1, 0, 1, 0]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [4, 4, 4, 4]) == True\n assert candidate(nums = [0, 0, 0, 0]) == True\n assert candidate(nums = [7, 11, 14, 12]) == True\n assert candidate(nums = [1, 2, 4, 8, 16, 32]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3]) == False\n assert candidate(nums = [1, 2, 3]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [2, 2]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10, 20, 30, 40, 50]) == False\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == True\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == True\n assert candidate(nums = [15, 15, 14, 14, 13, 13, 12, 12, 11, 11]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 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]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 4, 4, 4, 4]) == False\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60]) == 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 = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == True\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 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 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == True\n assert candidate(nums = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == True\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255]) == True\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 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]) == True\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 3, 3, 3, 3, 3, 3, 3, 3, 1]) == True\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == True\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == True\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == False\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == False\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23]) == False\n assert candidate(nums = [16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [1, 3, 2, 3, 2, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16]) == True\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == False\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [16, 8, 4, 2, 1, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == False\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]) == True\n assert candidate(nums = [17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31]) == True\n assert candidate(nums = [1, 3, 3, 1, 5, 5, 5]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 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]) == True\n assert candidate(nums = [3, 3, 4, 4, 4, 5, 5, 5]) == True\n assert candidate(nums = [17, 17, 34, 34, 1, 2, 3, 3, 2, 1]) == 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 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == True\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 4, 4, 5, 5]) == True\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == False\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == True\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == False\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n assert candidate(nums = [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 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == True\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256]) == True\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255]) == False\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == True\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == False\n", "comparison": "exact"}, "public_tests": ["[1,1,2]", "[0,1]", "[1,2,3]"], "hints": [], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().xorGame", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:28+00:00", "tests_total": 122, "tests_dropped": 6, "flags": [], "topic_tags": ["array", "math", "bit-manipulation", "brainteaser", "game-theory", "zero-sum-game", "impartial-game"]}, "language": "java", "interface": {"raw_signature": "public boolean xorGame(int[] nums) {", "container": "Solution", "callable": "xorGame", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 811, "task_id": "subdomain-visit-count", "difficulty": "Medium", "problem_description": "A website domain \"discuss.leetcode.com\" consists of various subdomains. At the top level, we have \"com\", at the next level, we have \"leetcode.com\" and at the lowest level, \"discuss.leetcode.com\". When we visit a domain like \"discuss.leetcode.com\", we will also visit the parent domains \"leetcode.com\" and \"com\" implicitly.\n\nA count-paired domain is a domain that has one of the two formats \"rep d1.d2.d3\" or \"rep d1.d2\" where rep is the number of visits to the domain and d1.d2.d3 is the domain itself.\n\n- For example, \"9001 discuss.leetcode.com\" is a count-paired domain that indicates that discuss.leetcode.com was visited 9001 times.\n\nGiven an array of count-paired domains cpdomains, return an array of the count-paired domains of each subdomain in the input. You may return the answer in any order.\n\nExample 1:\n\nInput: cpdomains = [\"9001 discuss.leetcode.com\"]\nOutput: [\"9001 leetcode.com\",\"9001 discuss.leetcode.com\",\"9001 com\"]\nExplanation: We only have one website domain: \"discuss.leetcode.com\".\nAs discussed above, the subdomain \"leetcode.com\" and \"com\" will also be visited. So they will all be visited 9001 times.\n\nExample 2:\n\nInput: cpdomains = [\"900 google.mail.com\", \"50 yahoo.com\", \"1 intel.mail.com\", \"5 wiki.org\"]\nOutput: [\"901 mail.com\",\"50 yahoo.com\",\"900 google.mail.com\",\"5 wiki.org\",\"5 org\",\"1 intel.mail.com\",\"951 com\"]\nExplanation: We will visit \"google.mail.com\" 900 times, \"yahoo.com\" 50 times, \"intel.mail.com\" once and \"wiki.org\" 5 times.\nFor the subdomains, we will visit \"mail.com\" 900 + 1 = 901 times, \"com\" 900 + 50 + 1 = 951 times, and \"org\" 5 times.\n\nConstraints:\n\n- 1 <= cpdomain.length <= 100\n- 1 <= cpdomain[i].length <= 100\n- cpdomain[i] follows either the \"rep_i d1_i.d2_i.d3_i\" format or the \"rep_i d1_i.d2_i\" format.\n- rep_i is an integer in the range [1, 10^4].\n- d1_i, d2_i, and d3_i consist of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(cpdomains=['1 x.y.z', '2 y.z', '3 z']), ['1 x.y.z', '3 y.z', '6 z'])\n assert answers_match(candidate(cpdomains=['1 a.com', '2 b.a.com', '3 c.b.a.com']), ['6 a.com', '6 com', '5 b.a.com', '3 c.b.a.com'])\n assert answers_match(candidate(cpdomains=['1 a.com', '2 a.b.com', '3 a.b.c.com']), ['1 a.com', '6 com', '2 a.b.com', '2 b.com', '3 a.b.c.com', '3 b.c.com', '3 c.com'])\n assert answers_match(candidate(cpdomains=['500 blog.example.co', '200 news.example.co', '100 example.co']), ['500 blog.example.co', '800 example.co', '800 co', '200 news.example.co'])\n assert answers_match(candidate(cpdomains=['900 google.mail.com', '50 yahoo.com', '1 intel.mail.com', '5 wiki.org']), ['900 google.mail.com', '901 mail.com', '951 com', '50 yahoo.com', '1 intel.mail.com', '5 wiki.org', '5 org'])\n assert answers_match(candidate(cpdomains=['50 mail.google.com', '1 mail.yahoo.com', '5 mail.msn.com']), ['50 mail.google.com', '50 google.com', '56 com', '1 mail.yahoo.com', '1 yahoo.com', '5 mail.msn.com', '5 msn.com'])\n assert answers_match(candidate(cpdomains=['9001 discuss.leetcode.com']), ['9001 discuss.leetcode.com', '9001 leetcode.com', '9001 com'])\n assert answers_match(candidate(cpdomains=['10 example.com', '5 example.co.uk', '3 sub.example.co.uk']), ['10 example.com', '10 com', '8 example.co.uk', '8 co.uk', '8 uk', '3 sub.example.co.uk'])\n assert answers_match(candidate(cpdomains=['100 x.y.z', '20 w.x.y.z', '30 v.w.x.y.z']), ['150 x.y.z', '150 y.z', '150 z', '50 w.x.y.z', '30 v.w.x.y.z'])\n assert answers_match(candidate(cpdomains=['1 example.com', '2 sub.example.com', '3 sub.sub.example.com']), ['6 example.com', '6 com', '5 sub.example.com', '3 sub.sub.example.com'])\n assert answers_match(candidate(cpdomains=['1000 main.domain.com', '500 sub.main.domain.com', '200 sub.domain.com']), ['1500 main.domain.com', '1700 domain.com', '1700 com', '500 sub.main.domain.com', '200 sub.domain.com'])\n assert answers_match(candidate(cpdomains=['100 a.com', '50 b.a.com', '25 c.b.a.com']), ['175 a.com', '175 com', '75 b.a.com', '25 c.b.a.com'])\n assert answers_match(candidate(cpdomains=['10 example.com', '5 sub.example.com', '3 subsub.example.com']), ['18 example.com', '18 com', '5 sub.example.com', '3 subsub.example.com'])\n assert answers_match(candidate(cpdomains=['700 tech.forum.net', '800 tech.net', '900 forum.net', '1000 net', '500 tech.forum.forge.net', '300 forum.forge.net', '200 forge.net']), ['700 tech.forum.net', '1600 forum.net', '4400 net', '800 tech.net', '500 tech.forum.forge.net', '800 forum.forge.net', '1000 forge.net'])\n assert answers_match(candidate(cpdomains=['300 deep.subdomain.example.com', '200 subdomain.example.com', '100 example.com', '150 another.subdomain.example.com', '50 yet.another.example.com']), ['300 deep.subdomain.example.com', '650 subdomain.example.com', '800 example.com', '800 com', '150 another.subdomain.example.com', '50 yet.another.example.com', '50 another.example.com'])\n assert answers_match(candidate(cpdomains=['3000 complex.sub.domain.com', '2000 sub.domain.com', '1000 domain.com', '500 verydeep.sub.domain.com', '100 verydeep.sub.sub.domain.com']), ['3000 complex.sub.domain.com', '5600 sub.domain.com', '6600 domain.com', '6600 com', '500 verydeep.sub.domain.com', '100 verydeep.sub.sub.domain.com', '100 sub.sub.domain.com'])\n assert answers_match(candidate(cpdomains=['300 www.example.co.uk', '200 mail.example.co.uk', '150 blog.example.co.uk', '100 co.uk']), ['300 www.example.co.uk', '650 example.co.uk', '750 co.uk', '750 uk', '200 mail.example.co.uk', '150 blog.example.co.uk'])\n assert answers_match(candidate(cpdomains=['600 alpha.beta.gamma.delta.com', '500 beta.gamma.delta.com', '400 gamma.delta.com', '300 delta.com', '200 alpha.com', '100 com']), ['600 alpha.beta.gamma.delta.com', '1100 beta.gamma.delta.com', '1500 gamma.delta.com', '1800 delta.com', '2100 com', '200 alpha.com'])\n assert answers_match(candidate(cpdomains=['1000 x.y.z.com', '500 y.z.com', '250 z.com', '150 a.b.y.z.com', '100 b.y.z.com', '75 y.z.com', '60 z.com', '40 w.x.y.z.com']), ['1040 x.y.z.com', '1865 y.z.com', '2175 z.com', '2175 com', '150 a.b.y.z.com', '250 b.y.z.com', '40 w.x.y.z.com'])\n assert answers_match(candidate(cpdomains=['100 one.two.three.four.com', '200 two.three.four.com', '150 three.four.com', '100 four.com', '75 one.two.four.com', '50 two.four.com', '40 four.com', '25 one.two.three.com', '100 two.three.com', '60 three.com', '35 com']), ['100 one.two.three.four.com', '300 two.three.four.com', '450 three.four.com', '715 four.com', '935 com', '75 one.two.four.com', '125 two.four.com', '25 one.two.three.com', '125 two.three.com', '185 three.com'])\n assert answers_match(candidate(cpdomains=['10 co.uk', '20 uk', '30 com', '40 google.com', '50 google.co.uk', '60 blog.google.co.uk', '70 news.google.co.uk', '80 mail.google.co.uk', '90 google.uk', '100 uk', '200 blog.uk', '300 news.uk', '400 mail.uk']), ['270 co.uk', '1380 uk', '70 com', '40 google.com', '260 google.co.uk', '60 blog.google.co.uk', '70 news.google.co.uk', '80 mail.google.co.uk', '90 google.uk', '200 blog.uk', '300 news.uk', '400 mail.uk'])\n assert answers_match(candidate(cpdomains=['100 example1.com', '200 example2.com', '300 example3.com', '400 example4.com', '500 example5.com', '600 example6.com', '700 example7.com', '800 example8.com', '900 example9.com', '1000 example10.com']), ['100 example1.com', '5500 com', '200 example2.com', '300 example3.com', '400 example4.com', '500 example5.com', '600 example6.com', '700 example7.com', '800 example8.com', '900 example9.com', '1000 example10.com'])\n assert answers_match(candidate(cpdomains=['1000 main.homepage.net', '2000 sub.main.homepage.net', '300 sub.homepage.net', '150 homepage.net', '500 main.net', '100 net', '250 sub.sub.main.homepage.net']), ['3250 main.homepage.net', '3700 homepage.net', '4300 net', '2250 sub.main.homepage.net', '300 sub.homepage.net', '500 main.net', '250 sub.sub.main.homepage.net'])\n assert answers_match(candidate(cpdomains=['1200 verydeep.subdomain.example.com', '300 deep.subdomain.example.com', '400 subdomain.example.com', '100 example.com']), ['1200 verydeep.subdomain.example.com', '1900 subdomain.example.com', '2000 example.com', '2000 com', '300 deep.subdomain.example.com'])\n assert answers_match(candidate(cpdomains=['800 blog.medium.com', '200 tech.medium.com', '300 news.medium.com', '100 medium.com', '500 articles.blog.medium.com']), ['1300 blog.medium.com', '1900 medium.com', '1900 com', '200 tech.medium.com', '300 news.medium.com', '500 articles.blog.medium.com'])\n assert answers_match(candidate(cpdomains=['1000 main.site.org', '500 sub1.main.site.org', '200 sub2.main.site.org', '100 site.org', '50 sub3.sub1.main.site.org', '25 sub4.sub1.main.site.org']), ['1775 main.site.org', '1875 site.org', '1875 org', '575 sub1.main.site.org', '200 sub2.main.site.org', '50 sub3.sub1.main.site.org', '25 sub4.sub1.main.site.org'])\n assert answers_match(candidate(cpdomains=['10000 top.level.domain.io', '9000 level.domain.io', '8000 domain.io', '7000 io', '6000 another.top.level.domain.io', '5000 another.level.domain.io', '4000 another.domain.io', '3000 another.io']), ['16000 top.level.domain.io', '30000 level.domain.io', '42000 domain.io', '52000 io', '6000 another.top.level.domain.io', '5000 another.level.domain.io', '4000 another.domain.io', '3000 another.io'])\n assert answers_match(candidate(cpdomains=['500 support.microsoft.com', '300 download.microsoft.com', '200 services.microsoft.com', '100 microsoft.com', '400 updates.microsoft.com', '150 secure.microsoft.com']), ['500 support.microsoft.com', '1650 microsoft.com', '1650 com', '300 download.microsoft.com', '200 services.microsoft.com', '400 updates.microsoft.com', '150 secure.microsoft.com'])\n assert answers_match(candidate(cpdomains=['100 forum.discussion.community.org', '50 news.discussion.community.org', '200 discussion.community.org', '100 community.org', '50 org', '300 updates.discussion.community.org']), ['100 forum.discussion.community.org', '650 discussion.community.org', '750 community.org', '800 org', '50 news.discussion.community.org', '300 updates.discussion.community.org'])\n assert answers_match(candidate(cpdomains=['150 mail.google.com', '50 docs.google.com', '200 accounts.google.com', '100 google.com', '300 app.mail.google.com']), ['450 mail.google.com', '800 google.com', '800 com', '50 docs.google.com', '200 accounts.google.com', '300 app.mail.google.com'])\n assert answers_match(candidate(cpdomains=['10000 main.prod.env.com', '5000 sub.main.prod.env.com', '2500 service.sub.main.prod.env.com', '1250 prod.env.com', '625 env.com', '312 helper.service.sub.main.prod.env.com', '156 feedback.helper.service.sub.main.prod.env.com']), ['17968 main.prod.env.com', '19218 prod.env.com', '19843 env.com', '19843 com', '7968 sub.main.prod.env.com', '2968 service.sub.main.prod.env.com', '468 helper.service.sub.main.prod.env.com', '156 feedback.helper.service.sub.main.prod.env.com'])\n assert answers_match(candidate(cpdomains=['1 abc.def.ghi', '2 abc.def', '3 def', '4 ghi', '5 abc', '6 abc.def.ghi.jkl', '7 def.ghi.jkl', '8 ghi.jkl', '9 jkl']), ['1 abc.def.ghi', '1 def.ghi', '5 ghi', '2 abc.def', '5 def', '5 abc', '6 abc.def.ghi.jkl', '13 def.ghi.jkl', '21 ghi.jkl', '30 jkl'])\n assert answers_match(candidate(cpdomains=['10000 main.example.com', '3000 sub1.main.example.com', '2000 sub2.sub1.main.example.com', '1500 sub.example.com', '1000 another.sub.example.com']), ['15000 main.example.com', '17500 example.com', '17500 com', '5000 sub1.main.example.com', '2000 sub2.sub1.main.example.com', '2500 sub.example.com', '1000 another.sub.example.com'])\n assert answers_match(candidate(cpdomains=['100 company.corp.local', '200 it.corp.local', '300 hr.corp.local', '400 dev.it.corp.local', '500 qa.it.corp.local', '600 design.it.corp.local', '700 finance.hr.corp.local', '800 marketing.hr.corp.local']), ['100 company.corp.local', '3600 corp.local', '3600 local', '1700 it.corp.local', '1800 hr.corp.local', '400 dev.it.corp.local', '500 qa.it.corp.local', '600 design.it.corp.local', '700 finance.hr.corp.local', '800 marketing.hr.corp.local'])\n assert answers_match(candidate(cpdomains=['1000 a.b.c.d.e.com', '500 f.g.c.d.e.com', '250 g.c.d.e.com', '125 c.d.e.com', '60 d.e.com', '30 e.com']), ['1000 a.b.c.d.e.com', '1000 b.c.d.e.com', '1875 c.d.e.com', '1935 d.e.com', '1965 e.com', '1965 com', '500 f.g.c.d.e.com', '750 g.c.d.e.com'])\n assert answers_match(candidate(cpdomains=['1 abc.com', '2 xyz.abc.com', '3 def.abc.com', '4 ghi.def.abc.com', '5 jkl.ghi.def.abc.com', '6 mno.jkl.ghi.def.abc.com']), ['21 abc.com', '21 com', '2 xyz.abc.com', '18 def.abc.com', '15 ghi.def.abc.com', '11 jkl.ghi.def.abc.com', '6 mno.jkl.ghi.def.abc.com'])\n assert answers_match(candidate(cpdomains=['1500 tech.gaming.website.com', '300 mobile.gaming.website.com', '200 gaming.website.com', '1000 website.com']), ['1500 tech.gaming.website.com', '2000 gaming.website.com', '3000 website.com', '3000 com', '300 mobile.gaming.website.com'])\n assert answers_match(candidate(cpdomains=['150 tech.productivitytools.io', '250 productivitytools.io', '400 blog.productivitytools.io', '300 dev.productivitytools.io', '200 docs.productivitytools.io', '100 io']), ['150 tech.productivitytools.io', '1300 productivitytools.io', '1400 io', '400 blog.productivitytools.io', '300 dev.productivitytools.io', '200 docs.productivitytools.io'])\n assert answers_match(candidate(cpdomains=['1500 forum.discussion.web', '2500 chat.forum.discussion.web', '1000 support.web', '500 help.support.web', '2000 help.web', '800 forum.web', '1200 web']), ['4000 forum.discussion.web', '4000 discussion.web', '9500 web', '2500 chat.forum.discussion.web', '1500 support.web', '500 help.support.web', '2000 help.web', '800 forum.web'])\n assert answers_match(candidate(cpdomains=['200 admin.internal.server.net', '150 db.internal.server.net', '100 internal.server.net', '50 server.net', '25 net']), ['200 admin.internal.server.net', '450 internal.server.net', '500 server.net', '525 net', '150 db.internal.server.net'])\n assert answers_match(candidate(cpdomains=['100 abc.def.com', '200 def.com', '300 ghi.jkl.com', '400 jkl.com', '500 mno.pqr.com', '600 pqr.com']), ['100 abc.def.com', '300 def.com', '2100 com', '300 ghi.jkl.com', '700 jkl.com', '500 mno.pqr.com', '1100 pqr.com'])\n assert answers_match(candidate(cpdomains=['1 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.com', '2 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.com', '3 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com']), ['1 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.com', '1 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.com', '1 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 m.n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 n.o.p.q.r.s.t.u.v.w.x.y.z.com', '1 o.p.q.r.s.t.u.v.w.x.y.z.com', '1 p.q.r.s.t.u.v.w.x.y.z.com', '1 q.r.s.t.u.v.w.x.y.z.com', '1 r.s.t.u.v.w.x.y.z.com', '1 s.t.u.v.w.x.y.z.com', '1 t.u.v.w.x.y.z.com', '1 u.v.w.x.y.z.com', '1 v.w.x.y.z.com', '1 w.x.y.z.com', '1 x.y.z.com', '1 y.z.com', '1 z.com', '6 com', '2 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.com', '2 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 l.m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 m.n.o.p.q.r.s.t.u.v.w.x.y.com', '2 n.o.p.q.r.s.t.u.v.w.x.y.com', '2 o.p.q.r.s.t.u.v.w.x.y.com', '2 p.q.r.s.t.u.v.w.x.y.com', '2 q.r.s.t.u.v.w.x.y.com', '2 r.s.t.u.v.w.x.y.com', '2 s.t.u.v.w.x.y.com', '2 t.u.v.w.x.y.com', '2 u.v.w.x.y.com', '2 v.w.x.y.com', '2 w.x.y.com', '2 x.y.com', '2 y.com', '3 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 k.l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 l.m.n.o.p.q.r.s.t.u.v.w.x.com', '3 m.n.o.p.q.r.s.t.u.v.w.x.com', '3 n.o.p.q.r.s.t.u.v.w.x.com', '3 o.p.q.r.s.t.u.v.w.x.com', '3 p.q.r.s.t.u.v.w.x.com', '3 q.r.s.t.u.v.w.x.com', '3 r.s.t.u.v.w.x.com', '3 s.t.u.v.w.x.com', '3 t.u.v.w.x.com', '3 u.v.w.x.com', '3 v.w.x.com', '3 w.x.com', '3 x.com'])\n assert answers_match(candidate(cpdomains=['1000 blog.devsite.co.uk', '2000 devsite.co.uk', '300 sub.devsite.co.uk', '150 sub.blog.devsite.co.uk', '500 blog.co.uk', '100 co.uk']), ['1150 blog.devsite.co.uk', '3450 devsite.co.uk', '4050 co.uk', '4050 uk', '300 sub.devsite.co.uk', '150 sub.blog.devsite.co.uk', '500 blog.co.uk'])\n assert answers_match(candidate(cpdomains=['1 example.net', '2 sub1.example.net', '3 sub2.sub1.example.net', '4 sub3.sub2.sub1.example.net', '5 sub4.sub3.sub2.sub1.example.net']), ['15 example.net', '15 net', '14 sub1.example.net', '12 sub2.sub1.example.net', '9 sub3.sub2.sub1.example.net', '5 sub4.sub3.sub2.sub1.example.net'])\n assert answers_match(candidate(cpdomains=['150 a.b.com', '200 b.com', '100 a.c.com', '120 c.com', '80 a.b.c.com', '50 b.c.com', '30 c.com', '25 d.e.f.g.com']), ['150 a.b.com', '350 b.com', '755 com', '100 a.c.com', '380 c.com', '80 a.b.c.com', '130 b.c.com', '25 d.e.f.g.com', '25 e.f.g.com', '25 f.g.com', '25 g.com'])\n assert answers_match(candidate(cpdomains=['10 tech.guru.experts.net', '20 experts.net', '30 guru.experts.net', '40 tech.net', '50 guru.net', '60 tech.guru.net', '70 guru.experts.net', '80 experts.tech.guru.net']), ['10 tech.guru.experts.net', '110 guru.experts.net', '130 experts.net', '360 net', '40 tech.net', '190 guru.net', '140 tech.guru.net', '80 experts.tech.guru.net'])\n assert answers_match(candidate(cpdomains=['300 tech.interview.prep.co', '200 coding.blog.tech.interview.prep.co', '100 interview.prep.co', '50 prep.co']), ['500 tech.interview.prep.co', '600 interview.prep.co', '650 prep.co', '650 co', '200 coding.blog.tech.interview.prep.co', '200 blog.tech.interview.prep.co'])\n assert answers_match(candidate(cpdomains=['1234 main.site.org', '4321 sub.site.org', '1111 sub.sub.site.org', '2222 site.org']), ['1234 main.site.org', '8888 site.org', '8888 org', '5432 sub.site.org', '1111 sub.sub.site.org'])\n assert answers_match(candidate(cpdomains=['12000 main.home.user.net', '6000 personal.main.home.user.net', '4000 work.home.user.net', '3000 personal.work.home.user.net', '2000 user.net', '1500 home.user.net', '1000 main.user.net']), ['18000 main.home.user.net', '26500 home.user.net', '29500 user.net', '29500 net', '6000 personal.main.home.user.net', '7000 work.home.user.net', '3000 personal.work.home.user.net', '1000 main.user.net'])\n assert answers_match(candidate(cpdomains=['9001 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '2 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', '3 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '4 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '5 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '6 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u', '7 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t', '8 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s', '9 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r', '10 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q', '11 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p', '12 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o', '13 a.b.c.d.e.f.g.h.i.j.k.l.m.n', '14 a.b.c.d.e.f.g.h.i.j.k.l.m', '15 a.b.c.d.e.f.g.h.i.j.k.l', '16 a.b.c.d.e.f.g.h.i.j.k', '17 a.b.c.d.e.f.g.h.i.j', '18 a.b.c.d.e.f.g.h.i', '19 a.b.c.d.e.f.g.h', '20 a.b.c.d.e.f.g']), ['9002 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', '9002 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', '9002 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 m.n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 n.o.p.q.r.s.t.u.v.w.x.y.z', '9002 o.p.q.r.s.t.u.v.w.x.y.z', '9002 p.q.r.s.t.u.v.w.x.y.z', '9002 q.r.s.t.u.v.w.x.y.z', '9002 r.s.t.u.v.w.x.y.z', '9002 s.t.u.v.w.x.y.z', '9002 t.u.v.w.x.y.z', '9002 u.v.w.x.y.z', '9002 v.w.x.y.z', '9002 w.x.y.z', '9002 x.y.z', '9002 y.z', '9002 z', '2 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', '2 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 k.l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 l.m.n.o.p.q.r.s.t.u.v.w.x.y', '2 m.n.o.p.q.r.s.t.u.v.w.x.y', '2 n.o.p.q.r.s.t.u.v.w.x.y', '2 o.p.q.r.s.t.u.v.w.x.y', '2 p.q.r.s.t.u.v.w.x.y', '2 q.r.s.t.u.v.w.x.y', '2 r.s.t.u.v.w.x.y', '2 s.t.u.v.w.x.y', '2 t.u.v.w.x.y', '2 u.v.w.x.y', '2 v.w.x.y', '2 w.x.y', '2 x.y', '2 y', '3 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 j.k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 k.l.m.n.o.p.q.r.s.t.u.v.w.x', '3 l.m.n.o.p.q.r.s.t.u.v.w.x', '3 m.n.o.p.q.r.s.t.u.v.w.x', '3 n.o.p.q.r.s.t.u.v.w.x', '3 o.p.q.r.s.t.u.v.w.x', '3 p.q.r.s.t.u.v.w.x', '3 q.r.s.t.u.v.w.x', '3 r.s.t.u.v.w.x', '3 s.t.u.v.w.x', '3 t.u.v.w.x', '3 u.v.w.x', '3 v.w.x', '3 w.x', '3 x', '4 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 i.j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 j.k.l.m.n.o.p.q.r.s.t.u.v.w', '4 k.l.m.n.o.p.q.r.s.t.u.v.w', '4 l.m.n.o.p.q.r.s.t.u.v.w', '4 m.n.o.p.q.r.s.t.u.v.w', '4 n.o.p.q.r.s.t.u.v.w', '4 o.p.q.r.s.t.u.v.w', '4 p.q.r.s.t.u.v.w', '4 q.r.s.t.u.v.w', '4 r.s.t.u.v.w', '4 s.t.u.v.w', '4 t.u.v.w', '4 u.v.w', '4 v.w', '4 w', '5 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 i.j.k.l.m.n.o.p.q.r.s.t.u.v', '5 j.k.l.m.n.o.p.q.r.s.t.u.v', '5 k.l.m.n.o.p.q.r.s.t.u.v', '5 l.m.n.o.p.q.r.s.t.u.v', '5 m.n.o.p.q.r.s.t.u.v', '5 n.o.p.q.r.s.t.u.v', '5 o.p.q.r.s.t.u.v', '5 p.q.r.s.t.u.v', '5 q.r.s.t.u.v', '5 r.s.t.u.v', '5 s.t.u.v', '5 t.u.v', '5 u.v', '5 v', '6 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u', '6 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u', '6 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u', '6 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u', '6 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u', '6 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u', '6 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u', '6 h.i.j.k.l.m.n.o.p.q.r.s.t.u', '6 i.j.k.l.m.n.o.p.q.r.s.t.u', '6 j.k.l.m.n.o.p.q.r.s.t.u', '6 k.l.m.n.o.p.q.r.s.t.u', '6 l.m.n.o.p.q.r.s.t.u', '6 m.n.o.p.q.r.s.t.u', '6 n.o.p.q.r.s.t.u', '6 o.p.q.r.s.t.u', '6 p.q.r.s.t.u', '6 q.r.s.t.u', '6 r.s.t.u', '6 s.t.u', '6 t.u', '6 u', '7 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t', '7 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t', '7 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t', '7 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t', '7 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t', '7 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t', '7 g.h.i.j.k.l.m.n.o.p.q.r.s.t', '7 h.i.j.k.l.m.n.o.p.q.r.s.t', '7 i.j.k.l.m.n.o.p.q.r.s.t', '7 j.k.l.m.n.o.p.q.r.s.t', '7 k.l.m.n.o.p.q.r.s.t', '7 l.m.n.o.p.q.r.s.t', '7 m.n.o.p.q.r.s.t', '7 n.o.p.q.r.s.t', '7 o.p.q.r.s.t', '7 p.q.r.s.t', '7 q.r.s.t', '7 r.s.t', '7 s.t', '7 t', '8 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s', '8 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s', '8 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s', '8 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s', '8 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s', '8 f.g.h.i.j.k.l.m.n.o.p.q.r.s', '8 g.h.i.j.k.l.m.n.o.p.q.r.s', '8 h.i.j.k.l.m.n.o.p.q.r.s', '8 i.j.k.l.m.n.o.p.q.r.s', '8 j.k.l.m.n.o.p.q.r.s', '8 k.l.m.n.o.p.q.r.s', '8 l.m.n.o.p.q.r.s', '8 m.n.o.p.q.r.s', '8 n.o.p.q.r.s', '8 o.p.q.r.s', '8 p.q.r.s', '8 q.r.s', '8 r.s', '8 s', '9 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r', '9 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r', '9 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r', '9 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r', '9 e.f.g.h.i.j.k.l.m.n.o.p.q.r', '9 f.g.h.i.j.k.l.m.n.o.p.q.r', '9 g.h.i.j.k.l.m.n.o.p.q.r', '9 h.i.j.k.l.m.n.o.p.q.r', '9 i.j.k.l.m.n.o.p.q.r', '9 j.k.l.m.n.o.p.q.r', '9 k.l.m.n.o.p.q.r', '9 l.m.n.o.p.q.r', '9 m.n.o.p.q.r', '9 n.o.p.q.r', '9 o.p.q.r', '9 p.q.r', '9 q.r', '9 r', '10 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q', '10 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q', '10 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q', '10 d.e.f.g.h.i.j.k.l.m.n.o.p.q', '10 e.f.g.h.i.j.k.l.m.n.o.p.q', '10 f.g.h.i.j.k.l.m.n.o.p.q', '10 g.h.i.j.k.l.m.n.o.p.q', '10 h.i.j.k.l.m.n.o.p.q', '10 i.j.k.l.m.n.o.p.q', '10 j.k.l.m.n.o.p.q', '10 k.l.m.n.o.p.q', '10 l.m.n.o.p.q', '10 m.n.o.p.q', '10 n.o.p.q', '10 o.p.q', '10 p.q', '10 q', '11 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p', '11 b.c.d.e.f.g.h.i.j.k.l.m.n.o.p', '11 c.d.e.f.g.h.i.j.k.l.m.n.o.p', '11 d.e.f.g.h.i.j.k.l.m.n.o.p', '11 e.f.g.h.i.j.k.l.m.n.o.p', '11 f.g.h.i.j.k.l.m.n.o.p', '11 g.h.i.j.k.l.m.n.o.p', '11 h.i.j.k.l.m.n.o.p', '11 i.j.k.l.m.n.o.p', '11 j.k.l.m.n.o.p', '11 k.l.m.n.o.p', '11 l.m.n.o.p', '11 m.n.o.p', '11 n.o.p', '11 o.p', '11 p', '12 a.b.c.d.e.f.g.h.i.j.k.l.m.n.o', '12 b.c.d.e.f.g.h.i.j.k.l.m.n.o', '12 c.d.e.f.g.h.i.j.k.l.m.n.o', '12 d.e.f.g.h.i.j.k.l.m.n.o', '12 e.f.g.h.i.j.k.l.m.n.o', '12 f.g.h.i.j.k.l.m.n.o', '12 g.h.i.j.k.l.m.n.o', '12 h.i.j.k.l.m.n.o', '12 i.j.k.l.m.n.o', '12 j.k.l.m.n.o', '12 k.l.m.n.o', '12 l.m.n.o', '12 m.n.o', '12 n.o', '12 o', '13 a.b.c.d.e.f.g.h.i.j.k.l.m.n', '13 b.c.d.e.f.g.h.i.j.k.l.m.n', '13 c.d.e.f.g.h.i.j.k.l.m.n', '13 d.e.f.g.h.i.j.k.l.m.n', '13 e.f.g.h.i.j.k.l.m.n', '13 f.g.h.i.j.k.l.m.n', '13 g.h.i.j.k.l.m.n', '13 h.i.j.k.l.m.n', '13 i.j.k.l.m.n', '13 j.k.l.m.n', '13 k.l.m.n', '13 l.m.n', '13 m.n', '13 n', '14 a.b.c.d.e.f.g.h.i.j.k.l.m', '14 b.c.d.e.f.g.h.i.j.k.l.m', '14 c.d.e.f.g.h.i.j.k.l.m', '14 d.e.f.g.h.i.j.k.l.m', '14 e.f.g.h.i.j.k.l.m', '14 f.g.h.i.j.k.l.m', '14 g.h.i.j.k.l.m', '14 h.i.j.k.l.m', '14 i.j.k.l.m', '14 j.k.l.m', '14 k.l.m', '14 l.m', '14 m', '15 a.b.c.d.e.f.g.h.i.j.k.l', '15 b.c.d.e.f.g.h.i.j.k.l', '15 c.d.e.f.g.h.i.j.k.l', '15 d.e.f.g.h.i.j.k.l', '15 e.f.g.h.i.j.k.l', '15 f.g.h.i.j.k.l', '15 g.h.i.j.k.l', '15 h.i.j.k.l', '15 i.j.k.l', '15 j.k.l', '15 k.l', '15 l', '16 a.b.c.d.e.f.g.h.i.j.k', '16 b.c.d.e.f.g.h.i.j.k', '16 c.d.e.f.g.h.i.j.k', '16 d.e.f.g.h.i.j.k', '16 e.f.g.h.i.j.k', '16 f.g.h.i.j.k', '16 g.h.i.j.k', '16 h.i.j.k', '16 i.j.k', '16 j.k', '16 k', '17 a.b.c.d.e.f.g.h.i.j', '17 b.c.d.e.f.g.h.i.j', '17 c.d.e.f.g.h.i.j', '17 d.e.f.g.h.i.j', '17 e.f.g.h.i.j', '17 f.g.h.i.j', '17 g.h.i.j', '17 h.i.j', '17 i.j', '17 j', '18 a.b.c.d.e.f.g.h.i', '18 b.c.d.e.f.g.h.i', '18 c.d.e.f.g.h.i', '18 d.e.f.g.h.i', '18 e.f.g.h.i', '18 f.g.h.i', '18 g.h.i', '18 h.i', '18 i', '19 a.b.c.d.e.f.g.h', '19 b.c.d.e.f.g.h', '19 c.d.e.f.g.h', '19 d.e.f.g.h', '19 e.f.g.h', '19 f.g.h', '19 g.h', '19 h', '20 a.b.c.d.e.f.g', '20 b.c.d.e.f.g', '20 c.d.e.f.g', '20 d.e.f.g', '20 e.f.g', '20 f.g', '20 g'])\n assert answers_match(candidate(cpdomains=['75 blog.health.com', '25 news.health.com', '50 health.com', '1000 medicine.com', '500 health.medicine.com']), ['75 blog.health.com', '150 health.com', '1650 com', '25 news.health.com', '1500 medicine.com', '500 health.medicine.com'])\n assert answers_match(candidate(cpdomains=['1234 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', '5678 y.x.w.v.u.t.s.r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a']), ['1234 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', '1234 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', '1234 c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 l.m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 m.n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 n.o.p.q.r.s.t.u.v.w.x.y.z', '1234 o.p.q.r.s.t.u.v.w.x.y.z', '1234 p.q.r.s.t.u.v.w.x.y.z', '1234 q.r.s.t.u.v.w.x.y.z', '1234 r.s.t.u.v.w.x.y.z', '1234 s.t.u.v.w.x.y.z', '1234 t.u.v.w.x.y.z', '1234 u.v.w.x.y.z', '1234 v.w.x.y.z', '1234 w.x.y.z', '1234 x.y.z', '1234 y.z', '1234 z', '5678 y.x.w.v.u.t.s.r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 x.w.v.u.t.s.r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 w.v.u.t.s.r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 v.u.t.s.r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 u.t.s.r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 t.s.r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 s.r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 r.q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 q.p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 p.o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 o.n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 n.m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 m.l.k.j.i.h.g.f.e.d.c.b.a', '5678 l.k.j.i.h.g.f.e.d.c.b.a', '5678 k.j.i.h.g.f.e.d.c.b.a', '5678 j.i.h.g.f.e.d.c.b.a', '5678 i.h.g.f.e.d.c.b.a', '5678 h.g.f.e.d.c.b.a', '5678 g.f.e.d.c.b.a', '5678 f.e.d.c.b.a', '5678 e.d.c.b.a', '5678 d.c.b.a', '5678 c.b.a', '5678 b.a', '5678 a'])\n assert answers_match(candidate(cpdomains=['9000 market.shop.com', '4500 tech.shop.com', '2250 blog.shop.com', '1125 shop.com', '562 support.blog.shop.com', '281 team.support.blog.shop.com', '140 help.team.support.blog.shop.com']), ['9000 market.shop.com', '17858 shop.com', '17858 com', '4500 tech.shop.com', '3233 blog.shop.com', '983 support.blog.shop.com', '421 team.support.blog.shop.com', '140 help.team.support.blog.shop.com'])\n assert answers_match(candidate(cpdomains=['1000 a.b.c.d.e', '500 f.g.h.i', '200 j.k.l', '300 m.n.o.p']), ['1000 a.b.c.d.e', '1000 b.c.d.e', '1000 c.d.e', '1000 d.e', '1000 e', '500 f.g.h.i', '500 g.h.i', '500 h.i', '500 i', '200 j.k.l', '200 k.l', '200 l', '300 m.n.o.p', '300 n.o.p', '300 o.p', '300 p'])\n assert answers_match(candidate(cpdomains=['10 main.business.world.com', '2 sub.main.business.world.com', '3 subsub.main.business.world.com', '4 business.world.com', '5 world.com']), ['15 main.business.world.com', '19 business.world.com', '24 world.com', '24 com', '2 sub.main.business.world.com', '3 subsub.main.business.world.com'])\n assert answers_match(candidate(cpdomains=['4000 blog.news.co', '1500 tech.blog.news.co', '1000 sports.co', '2000 sports.news.co', '500 tech.sports.co', '300 tech.co']), ['5500 blog.news.co', '7500 news.co', '9300 co', '1500 tech.blog.news.co', '1500 sports.co', '2000 sports.news.co', '500 tech.sports.co', '300 tech.co'])\n assert answers_match(candidate(cpdomains=['300 video.youtube.com', '200 music.youtube.com', '100 youtube.com', '500 m.youtube.com', '200 mobile.youtube.com', '100 google.com', '50 com']), ['300 video.youtube.com', '1300 youtube.com', '1450 com', '200 music.youtube.com', '500 m.youtube.com', '200 mobile.youtube.com', '100 google.com'])\n assert answers_match(candidate(cpdomains=['300 blog.businessinsider.com', '400 businessinsider.com', '200 news.businessinsider.com', '100 tech.businessinsider.com', '50 insider.com', '500 blog.insider.com', '200 tech.insider.com', '100 insider.com']), ['300 blog.businessinsider.com', '1000 businessinsider.com', '1850 com', '200 news.businessinsider.com', '100 tech.businessinsider.com', '850 insider.com', '500 blog.insider.com', '200 tech.insider.com'])\n assert answers_match(candidate(cpdomains=['500 blog.example.co', '300 news.example.co', '200 tech.example.co', '100 example.co', '50 sub.tech.example.co']), ['500 blog.example.co', '1150 example.co', '1150 co', '300 news.example.co', '250 tech.example.co', '50 sub.tech.example.co'])\n assert answers_match(candidate(cpdomains=['1234 company.job.search.engine.com', '4321 job.search.engine.com', '1111 search.engine.com', '2222 engine.com', '3333 com', '5678 tech.engine.com', '8765 tech.com']), ['1234 company.job.search.engine.com', '5555 job.search.engine.com', '6666 search.engine.com', '14566 engine.com', '26664 com', '5678 tech.engine.com', '8765 tech.com'])\n assert answers_match(candidate(cpdomains=['10000 web.page.co.uk', '2500 blog.page.co.uk', '1500 news.page.co.uk', '1000 mail.co.uk', '5000 co.uk', '7500 uk']), ['10000 web.page.co.uk', '14000 page.co.uk', '20000 co.uk', '27500 uk', '2500 blog.page.co.uk', '1500 news.page.co.uk', '1000 mail.co.uk'])\n assert answers_match(candidate(cpdomains=['1000 news.media.co', '5000 news.sport.media.co', '3000 news.culture.media.co', '2000 sport.media.co', '1500 culture.media.co', '1000 media.co', '800 news.co', '500 co']), ['1000 news.media.co', '13500 media.co', '14800 co', '5000 news.sport.media.co', '7000 sport.media.co', '3000 news.culture.media.co', '4500 culture.media.co', '800 news.co'])\n assert answers_match(candidate(cpdomains=['10 abc.def.ghi', '20 def.ghi', '30 ghi', '40 h.i.j', '50 i.j', '60 j', '70 k.l.m', '80 l.m', '90 m']), ['10 abc.def.ghi', '30 def.ghi', '60 ghi', '40 h.i.j', '90 i.j', '150 j', '70 k.l.m', '150 l.m', '240 m'])\n assert answers_match(candidate(cpdomains=['1000 main.domain.com', '500 sub.main.domain.com', '200 sub.domain.com', '300 another.sub.main.domain.com', '150 sub.another.main.domain.com', '50 yet.another.domain.com', '25 yet.sub.another.domain.com', '125 another.yet.sub.domain.com']), ['1950 main.domain.com', '2350 domain.com', '2350 com', '800 sub.main.domain.com', '325 sub.domain.com', '300 another.sub.main.domain.com', '150 sub.another.main.domain.com', '150 another.main.domain.com', '50 yet.another.domain.com', '75 another.domain.com', '25 yet.sub.another.domain.com', '25 sub.another.domain.com', '125 another.yet.sub.domain.com', '125 yet.sub.domain.com'])\n assert answers_match(candidate(cpdomains=['750 gaming.gamesite.net', '250 gamesite.net', '150 news.gamesite.net', '1000 gaming.net', '500 net', '200 streaming.gamesite.net', '100 gaming.streaming.gamesite.net']), ['750 gaming.gamesite.net', '1450 gamesite.net', '2950 net', '150 news.gamesite.net', '1000 gaming.net', '300 streaming.gamesite.net', '100 gaming.streaming.gamesite.net'])\n assert answers_match(candidate(cpdomains=['250 news.market.com', '150 finance.market.com', '1000 market.com', '500 news.international.market.com', '300 finance.international.market.com', '200 international.market.com']), ['250 news.market.com', '2400 market.com', '2400 com', '150 finance.market.com', '500 news.international.market.com', '1000 international.market.com', '300 finance.international.market.com'])\n assert answers_match(candidate(cpdomains=['1234 a.b.c.d.e.f.com', '5678 g.h.i.j.k.com', '9101 l.m.n.o.p.q.r.com', '1112 m.n.o.p.q.r.com', '1314 n.o.p.q.r.com']), ['1234 a.b.c.d.e.f.com', '1234 b.c.d.e.f.com', '1234 c.d.e.f.com', '1234 d.e.f.com', '1234 e.f.com', '1234 f.com', '18439 com', '5678 g.h.i.j.k.com', '5678 h.i.j.k.com', '5678 i.j.k.com', '5678 j.k.com', '5678 k.com', '9101 l.m.n.o.p.q.r.com', '10213 m.n.o.p.q.r.com', '11527 n.o.p.q.r.com', '11527 o.p.q.r.com', '11527 p.q.r.com', '11527 q.r.com', '11527 r.com'])\n assert answers_match(candidate(cpdomains=['500 x.y.z', '200 a.b.c.d', '100 e.f.g', '400 h.i.j.k.l', '600 m.n.o']), ['500 x.y.z', '500 y.z', '500 z', '200 a.b.c.d', '200 b.c.d', '200 c.d', '200 d', '100 e.f.g', '100 f.g', '100 g', '400 h.i.j.k.l', '400 i.j.k.l', '400 j.k.l', '400 k.l', '400 l', '600 m.n.o', '600 n.o', '600 o'])\n", "comparison": "unordered"}, "public_tests": ["[\"9001 discuss.leetcode.com\"]", "[\"900 google.mail.com\", \"50 yahoo.com\", \"1 intel.mail.com\", \"5 wiki.org\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["cpdomains"], "leetcode_dataset_entry_point": "Solution().subdomainVisits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:30+00:00", "tests_total": 68, "tests_dropped": 0, "flags": ["any_order"], "topic_tags": ["array", "hash-table", "string", "counting"]}, "language": "java", "interface": {"raw_signature": "public List subdomainVisits(String[] cpdomains) {", "container": "Solution", "callable": "subdomainVisits", "parameters": [{"name": "cpdomains", "type": "String[]"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 812, "task_id": "largest-triangle-area", "difficulty": "Easy", "problem_description": "Given an array of points on the X-Y plane points where points[i] = [x_i, y_i], return the area of the largest triangle that can be formed by any three different points. Answers within 10^-5 of the actual answer will be accepted.\n\nExample 1:\n\nInput: points = [[0,0],[0,1],[1,0],[0,2],[2,0]]\nOutput: 2.00000\nExplanation: The five points are shown in the above figure. The red triangle is the largest.\n\nExample 2:\n\nInput: points = [[1,0],[0,0],[0,1]]\nOutput: 0.50000\n\nConstraints:\n\n- 3 <= points.length <= 50\n- -50 <= x_i, y_i <= 50\n- All the given points are unique.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [1, 1], [0, 0]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [-2, -3], [-3, -1]]), 2.0)\n assert answers_match(candidate(points=[[-50, -50], [50, 50], [-50, 50], [50, -50], [0, 0]]), 5000.0)\n assert answers_match(candidate(points=[[0, 0], [0, 1], [1, 0], [0, 2], [2, 0]]), 2.0)\n assert answers_match(candidate(points=[[-50, -50], [-50, 50], [50, -50], [50, 50], [0, 0]]), 5000.0)\n assert answers_match(candidate(points=[[-50, -50], [50, 50], [0, 0]]), 0)\n assert answers_match(candidate(points=[[10, 10], [10, 20], [20, 10], [20, 20], [15, 15]]), 50.0)\n assert answers_match(candidate(points=[[1, 1], [2, 3], [3, 1]]), 2.0)\n assert answers_match(candidate(points=[[-1, 0], [0, -1], [1, 0], [0, 1], [0, 0]]), 1.0)\n assert answers_match(candidate(points=[[-50, -50], [-49, -49], [-48, -48], [0, 0]]), 0)\n assert answers_match(candidate(points=[[-50, -50], [50, 50], [0, 0], [25, -25], [-25, 25]]), 2500.0)\n assert answers_match(candidate(points=[[0, 0], [1, 0], [0, 1], [1, 1], [0.5, 0.5]]), 0.5)\n assert answers_match(candidate(points=[[1, 0], [0, 0], [0, 1]]), 0.5)\n assert answers_match(candidate(points=[[0, 0], [10, 0], [5, 5], [5, 10], [10, 5]]), 50.0)\n assert answers_match(candidate(points=[[0, 0], [1, 0], [0, 1], [1, 1], [2, 2]]), 1.5)\n assert answers_match(candidate(points=[[0, 0], [5, 0], [0, 5]]), 12.5)\n assert answers_match(candidate(points=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]), 0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [1, 1], [-1, 1], [1, -1], [0, 0]]), 2.0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3]]), 0)\n assert answers_match(candidate(points=[[10, 0], [0, 10], [-10, 0], [0, -10], [0, 0]]), 100.0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 0)\n assert answers_match(candidate(points=[[1, 1], [2, 3], [5, 1], [3, 4], [4, 5], [6, 2]]), 8.5)\n assert answers_match(candidate(points=[[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3]]), 0)\n assert answers_match(candidate(points=[[-10, -10], [10, 10], [-10, 10], [10, -10], [0, 0]]), 200.0)\n assert answers_match(candidate(points=[[5, 5], [5, -5], [-5, -5], [-5, 5], [0, 0]]), 50.0)\n assert answers_match(candidate(points=[[-50, -50], [0, 0], [50, 50], [-40, -40], [40, 40]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 0], [0, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]), 8.5)\n assert answers_match(candidate(points=[[10, 20], [20, 30], [30, 10], [40, 40], [50, 5], [0, 0]]), 900.0)\n assert answers_match(candidate(points=[[10, 10], [20, 20], [30, 30], [15, 25], [25, 15], [5, 5], [25, 35], [35, 25]]), 250.0)\n assert answers_match(candidate(points=[[0, 0], [10, 0], [5, 5], [8, 2], [3, 7], [6, 1], [9, 4], [2, 6], [7, 3], [4, 8]]), 40.0)\n assert answers_match(candidate(points=[[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [1, 1], [9, 9], [2, 2], [8, 8], [3, 3], [7, 7]]), 50.0)\n assert answers_match(candidate(points=[[-20, 20], [30, -30], [15, 45], [-40, -10], [25, 10], [0, 0], [-15, -25]]), 2475.0)\n assert answers_match(candidate(points=[[0, 0], [1, 0], [0, 1], [1, 1], [2, 0], [2, 1], [1, 2], [0, 2], [2, 2], [1.5, 1.5]]), 2.0)\n assert answers_match(candidate(points=[[5, 5], [15, 10], [25, 5], [15, 0], [25, 10], [35, 5]]), 100.0)\n assert answers_match(candidate(points=[[-40, 40], [40, -40], [-30, 30], [30, -30], [-20, 20], [20, -20], [-10, 10], [10, -10], [0, 0], [-5, 5], [5, -5]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]), 0)\n assert answers_match(candidate(points=[[-20, 30], [10, -40], [0, 0], [25, 25], [-30, -30], [40, 40], [5, 5]]), 2250.0)\n assert answers_match(candidate(points=[[-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [-3, 3], [-2, 2], [-1, 1]]), 18.0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]), 0)\n assert answers_match(candidate(points=[[-30, -20], [20, 25], [0, 0], [10, -10], [-25, 15], [5, 30], [-15, -25], [15, -5], [25, 10]]), 975.0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]), 0)\n assert answers_match(candidate(points=[[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [-10, -10], [-20, -20], [-30, -30], [-40, -40], [-50, -50]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]), 0)\n assert answers_match(candidate(points=[[-50, -40], [-40, -30], [-30, -20], [-20, -10], [-10, 0], [0, 10], [10, 20], [20, 30], [30, 40], [40, 50]]), 0)\n assert answers_match(candidate(points=[[-30, -30], [0, 0], [30, 30], [-20, 20], [20, -20], [-10, 10], [10, -10], [-5, 5], [5, -5]]), 1200.0)\n assert answers_match(candidate(points=[[-25, 0], [0, 25], [25, 0], [0, -25], [0, 0], [12.5, 12.5], [-12.5, -12.5]]), 625.0)\n assert answers_match(candidate(points=[[-10, 0], [10, 0], [0, -10], [0, 10], [5, 5], [-5, -5], [-5, 5], [5, -5], [1, 1], [-1, -1]]), 100.0)\n assert answers_match(candidate(points=[[-45, 45], [-35, 35], [-25, 25], [-15, 15], [-5, 5], [5, -5], [15, -15], [25, -25], [35, -35], [45, -45], [0, 0]]), 0)\n assert answers_match(candidate(points=[[-25, 25], [-50, 0], [0, 0], [25, 0], [50, 0], [0, -25], [0, 25], [25, 25], [-25, 0]]), 1562.5)\n assert answers_match(candidate(points=[[-10, 10], [-5, 5], [0, 0], [5, -5], [10, -10], [-8, 8], [-3, 3], [3, -3], [8, -8]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7], [-8, -8], [-9, -9], [-10, -10]]), 0)\n assert answers_match(candidate(points=[[50, 0], [0, 50], [-50, 0], [0, -50], [25, 25], [-25, -25], [25, -25], [-25, 25], [0, 0]]), 2500.0)\n assert answers_match(candidate(points=[[-10, -10], [-5, -5], [0, 0], [5, 5], [10, 10], [15, 15], [20, 20], [25, 25]]), 0)\n assert answers_match(candidate(points=[[-40, -40], [-20, -20], [-30, -10], [0, 0], [10, 10], [20, 20], [30, 30]]), 700.0)\n assert answers_match(candidate(points=[[1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24], [9, 27]]), 0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13]]), 11.5)\n assert answers_match(candidate(points=[[-2, -2], [-1, 1], [0, 0], [1, -1], [2, 2], [3, -3], [4, 4]]), 18.0)\n assert answers_match(candidate(points=[[-5, 5], [-4, 4], [-3, 3], [-2, 2], [-1, 1], [0, 0], [1, -1], [2, -2], [3, -3]]), 0)\n assert answers_match(candidate(points=[[-10, -20], [15, 25], [-15, -25], [20, 20], [0, 0], [25, 15], [-25, -15]]), 400.0)\n assert answers_match(candidate(points=[[-3, -3], [3, 3], [0, 0], [2, 4], [-2, -4], [5, -1], [-5, 1]]), 23.0)\n assert answers_match(candidate(points=[[-45, 45], [-40, 40], [-35, 35], [-30, 30], [-25, 25], [-20, 20], [-15, 15], [-10, 10], [-5, 5], [0, 0]]), 0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2], [4, 1], [4, 2], [5, 1], [5, 2], [6, 1], [6, 2]]), 2.5)\n assert answers_match(candidate(points=[[-45, -45], [45, 45], [45, -45], [-45, 45], [0, 0], [25, 25], [-25, -25], [25, -25], [-25, 25]]), 4050.0)\n assert answers_match(candidate(points=[[1, -1], [2, -2], [3, -3], [4, -4], [5, -5], [6, -6], [7, -7], [8, -8], [9, -9], [10, -10]]), 0)\n assert answers_match(candidate(points=[[-49, -49], [49, 49], [-49, 49], [49, -49], [0, 0], [25, 25], [-25, -25], [30, 30], [-30, -30]]), 4802.0)\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]), 0)\n assert answers_match(candidate(points=[[-1, 1], [-2, 2], [-3, 3], [-4, 4], [-5, 5], [1, -1], [2, -2], [3, -3], [4, -4], [5, -5]]), 0)\n assert answers_match(candidate(points=[[-49, -49], [-48, -48], [-47, -47], [-46, -46], [-45, -45], [-44, -44], [-43, -43], [-42, -42], [-41, -41], [-40, -40]]), 0)\n assert answers_match(candidate(points=[[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7]]), 10.5)\n assert answers_match(candidate(points=[[-30, -30], [-30, 30], [30, -30], [30, 30], [0, 0], [10, 10], [-10, -10], [10, -10], [-10, 10]]), 1800.0)\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18]]), 0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]), 7.5)\n assert answers_match(candidate(points=[[-25, 25], [0, 50], [25, -25], [50, 0], [-50, 0], [0, -50], [-25, -25], [25, 25], [0, 0]]), 2500.0)\n assert answers_match(candidate(points=[[-1, 1], [-2, 2], [-3, 3], [-4, 4], [-5, 5], [-6, 6], [-7, 7], [-8, 8], [-9, 9], [-10, 10]]), 0)\n assert answers_match(candidate(points=[[1, 1], [2, 1], [1, 2], [2, 2], [1, 3], [2, 3], [1, 4], [2, 4], [1, 5], [2, 5]]), 2.0)\n assert answers_match(candidate(points=[[1, 1], [2, 1], [1, 2], [2, 2], [3, 3], [4, 3], [3, 4], [4, 4], [5, 5], [6, 5], [5, 6], [6, 6]]), 4.5)\n assert answers_match(candidate(points=[[-5, -5], [5, 5], [-5, 5], [5, -5], [0, 0], [3, 3], [-3, -3], [2, 2], [-2, -2]]), 50.0)\n assert answers_match(candidate(points=[[-4, -4], [-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 0)\n assert answers_match(candidate(points=[[-20, 20], [-10, 10], [0, 0], [10, -10], [20, 20], [30, -30]]), 1000.0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [2, 1], [2, 2], [1, 3], [2, 3], [3, 1], [3, 2], [3, 3], [1, 4], [2, 4], [3, 4]]), 3.0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10]]), 22.5)\n assert answers_match(candidate(points=[[0, 1], [1, 0], [0, -1], [-1, 0], [2, 2], [-2, -2], [2, -2], [-2, 2], [3, 3], [-3, -3]]), 12.0)\n assert answers_match(candidate(points=[[-30, 30], [30, -30], [-20, 20], [20, -20], [-10, 10], [10, -10], [0, 0], [-5, 5], [5, -5]]), 0)\n assert answers_match(candidate(points=[[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 0], [2, 0], [0, 1], [1, 1], [2, 1], [0, 2], [1, 2], [2, 2], [0, 3], [1, 3], [2, 3]]), 3.0)\n assert answers_match(candidate(points=[[-10, -10], [10, 10], [-10, 10], [10, -10], [0, 0], [2, 2], [4, 4]]), 200.0)\n assert answers_match(candidate(points=[[-10, 0], [-20, 10], [0, 20], [10, 10], [20, -10], [10, -20], [0, -20], [-20, -10]]), 600.0)\n assert answers_match(candidate(points=[[0, 0], [0, 1], [1, 0], [1, 1], [0, 2], [1, 2], [2, 0], [2, 1], [2, 2], [0, 3]]), 3.0)\n assert answers_match(candidate(points=[[-20, 20], [-10, 10], [0, 0], [10, -10], [20, -20], [-15, 15], [-5, 5], [5, -5], [15, -15]]), 0)\n assert answers_match(candidate(points=[[-5, 0], [-4, 1], [-3, 2], [-2, 3], [-1, 4], [0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0]]), 25.0)\n assert answers_match(candidate(points=[[-10, -10], [-10, 10], [10, -10], [10, 10], [0, 0], [5, 5], [-5, 5], [-5, -5], [5, -5]]), 200.0)\n assert answers_match(candidate(points=[[-1, -1], [1, 1], [-2, -2], [2, 2], [-3, -3], [3, 3], [-4, -4], [4, 4], [-5, -5], [5, 5], [0, 0], [-0.5, -0.5], [0.5, 0.5]]), 0)\n assert answers_match(candidate(points=[[-10, 0], [0, -10], [10, 0], [0, 10], [5, 5], [-5, -5], [5, -5], [-5, 5], [2, 2], [-2, -2]]), 100.0)\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]), 0)\n assert answers_match(candidate(points=[[-40, 40], [-30, 30], [-20, 20], [-10, 10], [0, 0], [10, -10], [20, -20], [30, -30], [40, -40], [25, 25], [-25, -25]]), 2000.0)\n assert answers_match(candidate(points=[[-10, -10], [10, -10], [-10, 10], [10, 10], [0, 0], [5, 5], [-5, -5], [5, -5], [-5, 5]]), 200.0)\n assert answers_match(candidate(points=[[1, 2], [2, 3], [3, 1], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 12.5)\n assert answers_match(candidate(points=[[-1, -1], [-2, -2], [-3, -3], [1, 1], [2, 2], [3, 3], [0, 0], [-1, 1], [1, -1], [-2, 2], [2, -2]]), 12.0)\n assert answers_match(candidate(points=[[-20, 20], [-10, 10], [0, 0], [10, -10], [20, -20], [-20, -20], [-10, -10], [10, 10], [20, 20]]), 800.0)\n assert answers_match(candidate(points=[[0, 0], [1, 0], [0, 1], [-1, 0], [0, -1], [1, 1], [-1, 1], [-1, -1], [1, -1], [0, 2]]), 3.0)\n assert answers_match(candidate(points=[[0, 50], [50, 0], [25, 25], [-25, 25], [25, -25], [-25, -25], [10, 10], [-10, 10], [10, -10], [-10, -10]]), 2500.0)\n assert answers_match(candidate(points=[[-10, 10], [0, 0], [10, -10], [20, 20], [30, -30], [40, 40]]), 1600.0)\n assert answers_match(candidate(points=[[-5, 5], [5, -5], [10, 10], [-10, -10], [0, 0], [15, -15], [-15, 15], [5, 5], [-5, -5]]), 300.0)\n", "comparison": "float"}, "public_tests": ["[[0,0],[0,1],[1,0],[0,2],[2,0]]", "[[1,0],[0,0],[0,1]]"], "hints": [], "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().largestTriangleArea", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:33+00:00", "tests_total": 113, "tests_dropped": 5, "flags": ["figure_reference", "decimal_answer", "has_images"], "topic_tags": ["array", "math", "geometry", "polygons"]}, "language": "java", "interface": {"raw_signature": "public double largestTriangleArea(int[][] points) {", "container": "Solution", "callable": "largestTriangleArea", "parameters": [{"name": "points", "type": "int[][]"}], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 812, "task_id": "largest-triangle-area", "difficulty": "Easy", "problem_description": "Given an array of points on the X-Y plane points where points[i] = [x_i, y_i], return the area of the largest triangle that can be formed by any three different points. Answers within 10^-5 of the actual answer will be accepted.\n\nExample 1:\n\nInput: points = [[0,0],[0,1],[1,0],[0,2],[2,0]]\nOutput: 2.00000\nExplanation: The five points are shown in the above figure. The red triangle is the largest.\n\nExample 2:\n\nInput: points = [[1,0],[0,0],[0,1]]\nOutput: 0.50000\n\nConstraints:\n\n- 3 <= points.length <= 50\n- -50 <= x_i, y_i <= 50\n- All the given points are unique.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [1, 1], [0, 0]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [-2, -3], [-3, -1]]), 2.0)\n assert answers_match(candidate(points=[[-50, -50], [50, 50], [-50, 50], [50, -50], [0, 0]]), 5000.0)\n assert answers_match(candidate(points=[[0, 0], [0, 1], [1, 0], [0, 2], [2, 0]]), 2.0)\n assert answers_match(candidate(points=[[-50, -50], [-50, 50], [50, -50], [50, 50], [0, 0]]), 5000.0)\n assert answers_match(candidate(points=[[-50, -50], [50, 50], [0, 0]]), 0)\n assert answers_match(candidate(points=[[10, 10], [10, 20], [20, 10], [20, 20], [15, 15]]), 50.0)\n assert answers_match(candidate(points=[[1, 1], [2, 3], [3, 1]]), 2.0)\n assert answers_match(candidate(points=[[-1, 0], [0, -1], [1, 0], [0, 1], [0, 0]]), 1.0)\n assert answers_match(candidate(points=[[-50, -50], [-49, -49], [-48, -48], [0, 0]]), 0)\n assert answers_match(candidate(points=[[-50, -50], [50, 50], [0, 0], [25, -25], [-25, 25]]), 2500.0)\n assert answers_match(candidate(points=[[1, 0], [0, 0], [0, 1]]), 0.5)\n assert answers_match(candidate(points=[[0, 0], [10, 0], [5, 5], [5, 10], [10, 5]]), 50.0)\n assert answers_match(candidate(points=[[0, 0], [1, 0], [0, 1], [1, 1], [2, 2]]), 1.5)\n assert answers_match(candidate(points=[[0, 0], [5, 0], [0, 5]]), 12.5)\n assert answers_match(candidate(points=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]), 0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [1, 1], [-1, 1], [1, -1], [0, 0]]), 2.0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3]]), 0)\n assert answers_match(candidate(points=[[10, 0], [0, 10], [-10, 0], [0, -10], [0, 0]]), 100.0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 0)\n assert answers_match(candidate(points=[[1, 1], [2, 3], [5, 1], [3, 4], [4, 5], [6, 2]]), 8.5)\n assert answers_match(candidate(points=[[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3]]), 0)\n assert answers_match(candidate(points=[[-10, -10], [10, 10], [-10, 10], [10, -10], [0, 0]]), 200.0)\n assert answers_match(candidate(points=[[5, 5], [5, -5], [-5, -5], [-5, 5], [0, 0]]), 50.0)\n assert answers_match(candidate(points=[[-50, -50], [0, 0], [50, 50], [-40, -40], [40, 40]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 0], [0, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]), 8.5)\n assert answers_match(candidate(points=[[10, 20], [20, 30], [30, 10], [40, 40], [50, 5], [0, 0]]), 900.0)\n assert answers_match(candidate(points=[[10, 10], [20, 20], [30, 30], [15, 25], [25, 15], [5, 5], [25, 35], [35, 25]]), 250.0)\n assert answers_match(candidate(points=[[0, 0], [10, 0], [5, 5], [8, 2], [3, 7], [6, 1], [9, 4], [2, 6], [7, 3], [4, 8]]), 40.0)\n assert answers_match(candidate(points=[[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [1, 1], [9, 9], [2, 2], [8, 8], [3, 3], [7, 7]]), 50.0)\n assert answers_match(candidate(points=[[-20, 20], [30, -30], [15, 45], [-40, -10], [25, 10], [0, 0], [-15, -25]]), 2475.0)\n assert answers_match(candidate(points=[[5, 5], [15, 10], [25, 5], [15, 0], [25, 10], [35, 5]]), 100.0)\n assert answers_match(candidate(points=[[-40, 40], [40, -40], [-30, 30], [30, -30], [-20, 20], [20, -20], [-10, 10], [10, -10], [0, 0], [-5, 5], [5, -5]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]), 0)\n assert answers_match(candidate(points=[[-20, 30], [10, -40], [0, 0], [25, 25], [-30, -30], [40, 40], [5, 5]]), 2250.0)\n assert answers_match(candidate(points=[[-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [-3, 3], [-2, 2], [-1, 1]]), 18.0)\n assert answers_match(candidate(points=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]), 0)\n assert answers_match(candidate(points=[[-30, -20], [20, 25], [0, 0], [10, -10], [-25, 15], [5, 30], [-15, -25], [15, -5], [25, 10]]), 975.0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]), 0)\n assert answers_match(candidate(points=[[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [-10, -10], [-20, -20], [-30, -30], [-40, -40], [-50, -50]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]), 0)\n assert answers_match(candidate(points=[[-50, -40], [-40, -30], [-30, -20], [-20, -10], [-10, 0], [0, 10], [10, 20], [20, 30], [30, 40], [40, 50]]), 0)\n assert answers_match(candidate(points=[[-30, -30], [0, 0], [30, 30], [-20, 20], [20, -20], [-10, 10], [10, -10], [-5, 5], [5, -5]]), 1200.0)\n assert answers_match(candidate(points=[[-10, 0], [10, 0], [0, -10], [0, 10], [5, 5], [-5, -5], [-5, 5], [5, -5], [1, 1], [-1, -1]]), 100.0)\n assert answers_match(candidate(points=[[-45, 45], [-35, 35], [-25, 25], [-15, 15], [-5, 5], [5, -5], [15, -15], [25, -25], [35, -35], [45, -45], [0, 0]]), 0)\n assert answers_match(candidate(points=[[-25, 25], [-50, 0], [0, 0], [25, 0], [50, 0], [0, -25], [0, 25], [25, 25], [-25, 0]]), 1562.5)\n assert answers_match(candidate(points=[[-10, 10], [-5, 5], [0, 0], [5, -5], [10, -10], [-8, 8], [-3, 3], [3, -3], [8, -8]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7], [-8, -8], [-9, -9], [-10, -10]]), 0)\n assert answers_match(candidate(points=[[50, 0], [0, 50], [-50, 0], [0, -50], [25, 25], [-25, -25], [25, -25], [-25, 25], [0, 0]]), 2500.0)\n assert answers_match(candidate(points=[[-10, -10], [-5, -5], [0, 0], [5, 5], [10, 10], [15, 15], [20, 20], [25, 25]]), 0)\n assert answers_match(candidate(points=[[-40, -40], [-20, -20], [-30, -10], [0, 0], [10, 10], [20, 20], [30, 30]]), 700.0)\n assert answers_match(candidate(points=[[1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24], [9, 27]]), 0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13]]), 11.5)\n assert answers_match(candidate(points=[[-2, -2], [-1, 1], [0, 0], [1, -1], [2, 2], [3, -3], [4, 4]]), 18.0)\n assert answers_match(candidate(points=[[-5, 5], [-4, 4], [-3, 3], [-2, 2], [-1, 1], [0, 0], [1, -1], [2, -2], [3, -3]]), 0)\n assert answers_match(candidate(points=[[-10, -20], [15, 25], [-15, -25], [20, 20], [0, 0], [25, 15], [-25, -15]]), 400.0)\n assert answers_match(candidate(points=[[-3, -3], [3, 3], [0, 0], [2, 4], [-2, -4], [5, -1], [-5, 1]]), 23.0)\n assert answers_match(candidate(points=[[-45, 45], [-40, 40], [-35, 35], [-30, 30], [-25, 25], [-20, 20], [-15, 15], [-10, 10], [-5, 5], [0, 0]]), 0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2], [4, 1], [4, 2], [5, 1], [5, 2], [6, 1], [6, 2]]), 2.5)\n assert answers_match(candidate(points=[[-45, -45], [45, 45], [45, -45], [-45, 45], [0, 0], [25, 25], [-25, -25], [25, -25], [-25, 25]]), 4050.0)\n assert answers_match(candidate(points=[[1, -1], [2, -2], [3, -3], [4, -4], [5, -5], [6, -6], [7, -7], [8, -8], [9, -9], [10, -10]]), 0)\n assert answers_match(candidate(points=[[-49, -49], [49, 49], [-49, 49], [49, -49], [0, 0], [25, 25], [-25, -25], [30, 30], [-30, -30]]), 4802.0)\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]), 0)\n assert answers_match(candidate(points=[[-1, 1], [-2, 2], [-3, 3], [-4, 4], [-5, 5], [1, -1], [2, -2], [3, -3], [4, -4], [5, -5]]), 0)\n assert answers_match(candidate(points=[[-49, -49], [-48, -48], [-47, -47], [-46, -46], [-45, -45], [-44, -44], [-43, -43], [-42, -42], [-41, -41], [-40, -40]]), 0)\n assert answers_match(candidate(points=[[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7]]), 10.5)\n assert answers_match(candidate(points=[[-30, -30], [-30, 30], [30, -30], [30, 30], [0, 0], [10, 10], [-10, -10], [10, -10], [-10, 10]]), 1800.0)\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18]]), 0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]), 7.5)\n assert answers_match(candidate(points=[[-25, 25], [0, 50], [25, -25], [50, 0], [-50, 0], [0, -50], [-25, -25], [25, 25], [0, 0]]), 2500.0)\n assert answers_match(candidate(points=[[-1, 1], [-2, 2], [-3, 3], [-4, 4], [-5, 5], [-6, 6], [-7, 7], [-8, 8], [-9, 9], [-10, 10]]), 0)\n assert answers_match(candidate(points=[[1, 1], [2, 1], [1, 2], [2, 2], [1, 3], [2, 3], [1, 4], [2, 4], [1, 5], [2, 5]]), 2.0)\n assert answers_match(candidate(points=[[1, 1], [2, 1], [1, 2], [2, 2], [3, 3], [4, 3], [3, 4], [4, 4], [5, 5], [6, 5], [5, 6], [6, 6]]), 4.5)\n assert answers_match(candidate(points=[[-5, -5], [5, 5], [-5, 5], [5, -5], [0, 0], [3, 3], [-3, -3], [2, 2], [-2, -2]]), 50.0)\n assert answers_match(candidate(points=[[-4, -4], [-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 0)\n assert answers_match(candidate(points=[[-20, 20], [-10, 10], [0, 0], [10, -10], [20, 20], [30, -30]]), 1000.0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [2, 1], [2, 2], [1, 3], [2, 3], [3, 1], [3, 2], [3, 3], [1, 4], [2, 4], [3, 4]]), 3.0)\n assert answers_match(candidate(points=[[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10]]), 22.5)\n assert answers_match(candidate(points=[[0, 1], [1, 0], [0, -1], [-1, 0], [2, 2], [-2, -2], [2, -2], [-2, 2], [3, 3], [-3, -3]]), 12.0)\n assert answers_match(candidate(points=[[-30, 30], [30, -30], [-20, 20], [20, -20], [-10, 10], [10, -10], [0, 0], [-5, 5], [5, -5]]), 0)\n assert answers_match(candidate(points=[[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50]]), 0)\n assert answers_match(candidate(points=[[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 0], [2, 0], [0, 1], [1, 1], [2, 1], [0, 2], [1, 2], [2, 2], [0, 3], [1, 3], [2, 3]]), 3.0)\n assert answers_match(candidate(points=[[-10, -10], [10, 10], [-10, 10], [10, -10], [0, 0], [2, 2], [4, 4]]), 200.0)\n assert answers_match(candidate(points=[[-10, 0], [-20, 10], [0, 20], [10, 10], [20, -10], [10, -20], [0, -20], [-20, -10]]), 600.0)\n assert answers_match(candidate(points=[[0, 0], [0, 1], [1, 0], [1, 1], [0, 2], [1, 2], [2, 0], [2, 1], [2, 2], [0, 3]]), 3.0)\n assert answers_match(candidate(points=[[-20, 20], [-10, 10], [0, 0], [10, -10], [20, -20], [-15, 15], [-5, 5], [5, -5], [15, -15]]), 0)\n assert answers_match(candidate(points=[[-5, 0], [-4, 1], [-3, 2], [-2, 3], [-1, 4], [0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0]]), 25.0)\n assert answers_match(candidate(points=[[-10, -10], [-10, 10], [10, -10], [10, 10], [0, 0], [5, 5], [-5, 5], [-5, -5], [5, -5]]), 200.0)\n assert answers_match(candidate(points=[[-10, 0], [0, -10], [10, 0], [0, 10], [5, 5], [-5, -5], [5, -5], [-5, 5], [2, 2], [-2, -2]]), 100.0)\n assert answers_match(candidate(points=[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]), 0)\n assert answers_match(candidate(points=[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]), 0)\n assert answers_match(candidate(points=[[-40, 40], [-30, 30], [-20, 20], [-10, 10], [0, 0], [10, -10], [20, -20], [30, -30], [40, -40], [25, 25], [-25, -25]]), 2000.0)\n assert answers_match(candidate(points=[[-10, -10], [10, -10], [-10, 10], [10, 10], [0, 0], [5, 5], [-5, -5], [5, -5], [-5, 5]]), 200.0)\n assert answers_match(candidate(points=[[1, 2], [2, 3], [3, 1], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), 12.5)\n assert answers_match(candidate(points=[[-1, -1], [-2, -2], [-3, -3], [1, 1], [2, 2], [3, 3], [0, 0], [-1, 1], [1, -1], [-2, 2], [2, -2]]), 12.0)\n assert answers_match(candidate(points=[[-20, 20], [-10, 10], [0, 0], [10, -10], [20, -20], [-20, -20], [-10, -10], [10, 10], [20, 20]]), 800.0)\n assert answers_match(candidate(points=[[0, 0], [1, 0], [0, 1], [-1, 0], [0, -1], [1, 1], [-1, 1], [-1, -1], [1, -1], [0, 2]]), 3.0)\n assert answers_match(candidate(points=[[0, 50], [50, 0], [25, 25], [-25, 25], [25, -25], [-25, -25], [10, 10], [-10, 10], [10, -10], [-10, -10]]), 2500.0)\n assert answers_match(candidate(points=[[-10, 10], [0, 0], [10, -10], [20, 20], [30, -30], [40, 40]]), 1600.0)\n assert answers_match(candidate(points=[[-5, 5], [5, -5], [10, 10], [-10, -10], [0, 0], [15, -15], [-15, 15], [5, 5], [-5, -5]]), 300.0)\n", "comparison": "float"}, "public_tests": ["[[0,0],[0,1],[1,0],[0,2],[2,0]]", "[[1,0],[0,0],[0,1]]"], "hints": [], "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().largestTriangleArea", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:33+00:00", "tests_total": 113, "tests_dropped": 9, "flags": ["figure_reference", "decimal_answer", "has_images"], "topic_tags": ["array", "math", "geometry", "polygons"]}, "language": "java", "interface": {"raw_signature": "public double largestTriangleArea(int[][] points) {", "container": "Solution", "callable": "largestTriangleArea", "parameters": [{"name": "points", "type": "int[][]"}], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 813, "task_id": "largest-sum-of-averages", "difficulty": "Medium", "problem_description": "You are given an integer array nums and an integer k. You can partition the array into at most k non-empty adjacent subarrays. The score of a partition is the sum of the averages of each subarray.\n\nNote that the partition must use every integer in nums, and that the score is not necessarily an integer.\n\nReturn the maximum score you can achieve of all the possible partitions. Answers within 10^-6 of the actual answer will be accepted.\n\nExample 1:\n\nInput: nums = [9,1,2,3,9], k = 3\nOutput: 20.00000\nExplanation:\nThe best choice is to partition nums into [9], [1, 2, 3], [9]. The answer is 9 + (1 + 2 + 3) / 3 + 9 = 20.\nWe could have also partitioned nums into [9, 1], [2], [3, 9], for example.\nThat partition would lead to a score of 5 + 2 + 6 = 13, which is worse.\n\nExample 2:\n\nInput: nums = [1,2,3,4,5,6,7], k = 4\nOutput: 20.50000\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- 1 <= nums[i] <= 10^4\n- 1 <= k <= nums.length\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5], k=5), 15.0)\n assert answers_match(candidate(nums=[9, 1, 2, 3, 9], k=3), 20.0)\n assert answers_match(candidate(nums=[1, 2, 3], k=1), 2.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7], k=1), 4.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7], k=4), 20.5)\n assert answers_match(candidate(nums=[4, 1, 7, 5, 6, 2, 3], k=4), 18.166666666666664)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50], k=5), 150.0)\n assert answers_match(candidate(nums=[5, 5, 5, 5, 5], k=1), 5.0)\n assert answers_match(candidate(nums=[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], k=5), 50.0)\n assert answers_match(candidate(nums=[5, 5, 5, 5, 5], k=3), 15.0)\n assert answers_match(candidate(nums=[1, 2, 3], k=2), 4.5)\n assert answers_match(candidate(nums=[100, 200, 300, 400], k=2), 600.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7], k=7), 28.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4], k=2), 6.0)\n assert answers_match(candidate(nums=[9, 8, 7, 6, 5, 4, 3, 2, 1], k=4), 27.5)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=10), 55.0)\n assert answers_match(candidate(nums=[5, 3, 8, 1, 9, 2], k=3), 16.0)\n assert answers_match(candidate(nums=[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], k=5), 37.5)\n assert answers_match(candidate(nums=[5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], k=8), 125.17647058823529)\n assert answers_match(candidate(nums=[3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45], k=8), 265.5)\n assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=5), 5.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=5), 37.5)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50], k=2), 75.0)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150], k=3), 360.0)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], k=10), 550.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], k=3), 36.0)\n assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=10), 10.0)\n assert answers_match(candidate(nums=[100, 100, 100, 100, 100, 100, 100, 100, 100, 100], k=10), 1000.0)\n assert answers_match(candidate(nums=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59], k=15), 660.0)\n assert answers_match(candidate(nums=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], k=10), 50.0)\n assert answers_match(candidate(nums=[9, 1, 2, 3, 9, 1, 2, 3, 9], k=3), 21.0)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], k=5), 375.0)\n assert answers_match(candidate(nums=[5, 3, 6, 4, 8, 9, 1, 2], k=3), 16.5)\n assert answers_match(candidate(nums=[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], k=2), 15.0)\n assert answers_match(candidate(nums=[100, 10, 1, 10, 100, 100, 1, 10, 100, 100, 1, 10, 100], k=5), 370.14285714285717)\n assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=1), 1.0)\n assert answers_match(candidate(nums=[5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195], k=6), 950.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=10), 55.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=1), 5.5)\n assert answers_match(candidate(nums=[9, 1, 2, 3, 9, 1, 2, 3, 9, 1, 2, 3], k=4), 23.0)\n assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=5), 5.0)\n assert answers_match(candidate(nums=[4, 5, 6, 7, 8, 9, 10, 11, 12, 13], k=3), 32.5)\n assert answers_match(candidate(nums=[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], k=6), 102.5)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], k=5), 60.0)\n assert answers_match(candidate(nums=[1, 2, 2, 3, 3, 3, 4, 4, 4, 4], k=5), 18.333333333333332)\n assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=3), 3.0)\n assert answers_match(candidate(nums=[15, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10], k=5), 55.0)\n assert answers_match(candidate(nums=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], k=15), 75.0)\n assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=3), 3.0)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200], k=8), 1260.0)\n assert answers_match(candidate(nums=[9, 1, 4, 3, 8, 7, 5, 6, 2], k=4), 24.666666666666664)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], k=5), 375.0)\n assert answers_match(candidate(nums=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], k=1), 5.0)\n assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=10), 10.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], k=20), 405.0)\n assert answers_match(candidate(nums=[10, 20, 10, 20, 10, 20, 10, 20, 10, 20], k=5), 81.66666666666667)\n assert answers_match(candidate(nums=[5, 3, 8, 1, 9, 2, 6, 7], k=3), 18.25)\n assert answers_match(candidate(nums=[3, 1, 2, 4, 5, 6, 7, 8, 9, 10], k=3), 23.5)\n assert answers_match(candidate(nums=[9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1], k=5), 35.0625)\n assert answers_match(candidate(nums=[9, 8, 7, 6, 5, 4, 3, 2, 1], k=5), 33.0)\n assert answers_match(candidate(nums=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000], k=5), 50000.0)\n assert answers_match(candidate(nums=[9, 1, 2, 3, 9, 5, 7, 8], k=3), 21.5)\n assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=50), 50.0)\n assert answers_match(candidate(nums=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], k=5), 25.0)\n assert answers_match(candidate(nums=[10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991], k=5), 49987.5)\n assert answers_match(candidate(nums=[4, 3, 2, 6, 2, 3, 4, 5, 1, 2], k=4), 15.333333333333334)\n assert answers_match(candidate(nums=[100, 200, 300, 400, 500], k=2), 750.0)\n assert answers_match(candidate(nums=[2, 3, 4, 5, 6, 7, 8, 9], k=3), 21.5)\n assert answers_match(candidate(nums=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], k=10), 5500.0)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], k=1), 55.0)\n assert answers_match(candidate(nums=[5, 6, 1, 8, 4, 9], k=2), 13.8)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], k=5), 82.5)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], k=3), 235.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], k=7), 80.0)\n assert answers_match(candidate(nums=[1, 100, 1, 100, 1, 100, 1, 100, 1, 100], k=5), 318.5)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], k=15), 120.0)\n assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=15), 15.0)\n assert answers_match(candidate(nums=[5, 2, 3, 1, 5, 2, 3, 1, 5, 2, 3, 1, 5, 2, 3, 1, 5, 2, 3, 1], k=7), 24.32857142857143)\n assert answers_match(candidate(nums=[9, 7, 5, 3, 1, 2, 4, 6, 8, 10], k=2), 15.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], k=2), 22.5)\n assert answers_match(candidate(nums=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], k=2), 150.0)\n assert answers_match(candidate(nums=[5, 1, 4, 2, 3, 6, 8, 7], k=3), 18.5)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], k=20), 210.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=3), 23.5)\n assert answers_match(candidate(nums=[9, 1, 2, 3, 9, 1, 2, 3, 9, 1, 2, 3, 9, 1, 2, 3], k=6), 34.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], k=10), 150.0)\n assert answers_match(candidate(nums=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], k=5), 3750.0)\n assert answers_match(candidate(nums=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], k=10), 10.0)\n assert answers_match(candidate(nums=[1, 100, 2, 100, 3, 100, 4, 100, 5, 100], k=5), 322.49999999999994)\n assert answers_match(candidate(nums=[10000, 10000, 10000, 10000, 10000], k=3), 30000.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], k=10), 150.0)\n assert answers_match(candidate(nums=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], k=4), 58.0)\n assert answers_match(candidate(nums=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], k=2), 1500.0)\n assert answers_match(candidate(nums=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], k=25), 937.5)\n assert answers_match(candidate(nums=[9, 8, 7, 6, 5, 4, 3, 2, 1], k=3), 21.0)\n assert answers_match(candidate(nums=[9, 1, 2, 3, 9, 8, 7, 6, 5, 4], k=5), 33.5)\n assert answers_match(candidate(nums=[1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100], k=10), 670.0)\n assert answers_match(candidate(nums=[9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9], k=20), 180.0)\n assert answers_match(candidate(nums=[9, 8, 7, 6, 5, 4, 3, 2, 1], k=9), 45.0)\n assert answers_match(candidate(nums=[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], k=10), 50.0)\n", "comparison": "float"}, "public_tests": ["[9,1,2,3,9]\n3", "[1,2,3,4,5,6,7]\n4"], "hints": [], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().largestSumOfAverages", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:35+00:00", "tests_total": 102, "tests_dropped": 2, "flags": ["decimal_answer"], "topic_tags": ["array", "dynamic-programming", "prefix-sum"]}, "language": "java", "interface": {"raw_signature": "public double largestSumOfAverages(int[] nums, int k) {", "container": "Solution", "callable": "largestSumOfAverages", "parameters": [{"name": "nums", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 815, "task_id": "bus-routes", "difficulty": "Hard", "problem_description": "You are given an array routes representing bus routes where routes[i] is a bus route that the i^th bus repeats forever.\n\n- For example, if routes[0] = [1, 5, 7], this means that the 0^th bus travels in the sequence 1 -> 5 -> 7 -> 1 -> 5 -> 7 -> 1 -> ... forever.\n\nYou will start at the bus stop source (You are not on any bus initially), and you want to go to the bus stop target. You can travel between bus stops by buses only.\n\nReturn the least number of buses you must take to travel from source to target. Return -1 if it is not possible.\n\nExample 1:\n\nInput: routes = [[1,2,7],[3,6,7]], source = 1, target = 6\nOutput: 2\nExplanation: The best strategy is take the first bus to the bus stop 7, then take the second bus to the bus stop 6.\n\nExample 2:\n\nInput: routes = [[7,12],[4,5,15],[6],[15,19],[9,12,13]], source = 15, target = 12\nOutput: -1\n\nConstraints:\n\n- 1 <= routes.length <= 500.\n- 1 <= routes[i].length <= 10^5\n- All the values of routes[i] are unique.\n- sum(routes[i].length) <= 10^5\n- 0 <= routes[i][j] < 10^6\n- 0 <= source, target < 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(routes = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],source = 1,target = 9) == -1\n assert candidate(routes = [[1, 2, 3, 4, 5]],source = 1,target = 5) == 1\n assert candidate(routes = [[7, 12], [4, 5, 15], [6], [15, 19], [9, 12, 13]],source = 15,target = 12) == -1\n assert candidate(routes = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],source = 1,target = 8) == -1\n assert candidate(routes = [[1, 2, 3], [3, 4, 5], [5, 6, 1]],source = 2,target = 6) == 2\n assert candidate(routes = [[1, 5, 7], [1, 5, 3], [3, 7, 9]],source = 1,target = 9) == 2\n assert candidate(routes = [[1, 2, 3], [4, 5, 6]],source = 1,target = 6) == -1\n assert candidate(routes = [[1, 7], [3, 7], [5, 7], [7, 9]],source = 1,target = 9) == 2\n assert candidate(routes = [[1, 2, 3], [3, 4, 5], [5, 6, 1]],source = 1,target = 5) == 1\n assert candidate(routes = [[1, 7], [3, 5]],source = 5,target = 7) == -1\n assert candidate(routes = [[1, 5, 9], [3, 5, 7], [7, 8, 9]],source = 1,target = 8) == 2\n assert candidate(routes = [[1, 2, 3], [3, 4, 5], [5, 6, 7]],source = 1,target = 7) == 3\n assert candidate(routes = [[1, 2, 7], [3, 6, 7]],source = 1,target = 6) == 2\n assert candidate(routes = [[1, 2, 3], [3, 4, 5], [5, 6, 1], [6, 7, 8], [8, 9, 10], [10, 1, 2]],source = 1,target = 10) == 1\n assert candidate(routes = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12], [11, 12, 13], [12, 13, 14], [13, 14, 15], [14, 15, 16], [15, 16, 17], [16, 17, 18], [17, 18, 19], [18, 19, 20], [19, 20, 21], [20, 21, 22], [21, 22, 23], [22, 23, 24], [23, 24, 25]],source = 1,target = 25) == 12\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11]],source = 1,target = 11) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [5, 10, 15, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50]],source = 1,target = 50) == -1\n assert candidate(routes = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [5, 10, 15, 20, 25, 30], [15, 25, 35, 45, 55, 65]],source = 1,target = 65) == 3\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8, 10, 12, 14, 16, 18], [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]],source = 1,target = 21) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [5, 10, 15, 20]],source = 1,target = 20) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [19, 20, 21, 22, 23, 24, 25, 26, 27, 28], [28, 29, 30, 1]],source = 1,target = 30) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5], [5, 6, 7, 8, 9], [9, 10, 11, 12, 13], [13, 14, 15, 16, 17], [17, 18, 19, 20, 21], [21, 22, 23, 24, 25]],source = 1,target = 25) == 6\n assert candidate(routes = [[1, 10, 20, 30, 40], [2, 11, 21, 31, 41], [3, 12, 22, 32, 42], [4, 13, 23, 33, 43], [5, 14, 24, 34, 44]],source = 1,target = 44) == -1\n assert candidate(routes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]],source = 1,target = 75) == 2\n assert candidate(routes = [[1, 10, 15, 20], [2, 10, 12], [10, 15, 25], [5, 15, 30], [1, 5]],source = 1,target = 25) == 2\n assert candidate(routes = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],source = 1,target = 30) == -1\n assert candidate(routes = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100]],source = 100,target = 500) == 1\n assert candidate(routes = [[1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49], [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50], [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47], [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [1, 11, 21, 31, 41], [5, 15, 25, 35, 45]],source = 1,target = 50) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50], [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], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49]],source = 1,target = 50) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29], [29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43]],source = 1,target = 43) == 3\n assert candidate(routes = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [4, 7, 10, 13, 16], [5, 8, 11, 14, 17]],source = 1,target = 17) == 2\n assert candidate(routes = [[3, 11, 16, 18, 23], [2, 10, 12, 21, 22, 24, 26, 33, 34, 38], [11, 13, 19, 32, 36, 43], [6, 16, 19, 26, 29, 34, 36, 37, 38, 39, 43, 44], [5, 9, 10, 12, 18, 21, 24, 27, 28, 32, 33, 35, 40, 41, 42, 45, 46, 48, 49], [2, 5, 8, 9, 13, 14, 17, 21, 22, 23, 24, 25, 30, 31, 33, 35, 41, 44, 45, 47], [3, 6, 7, 8, 10, 12, 14, 15, 17, 20, 21, 23, 27, 31, 32, 33, 37, 40, 41, 43, 45, 46, 47, 48, 49], [1, 6, 9, 13, 14, 25, 31, 32, 34, 35, 40, 41, 43, 44, 45, 46, 47, 48, 49], [3, 14, 17, 20, 21, 22, 26, 28, 30, 31, 32, 35, 37, 39, 40, 41, 42, 43, 44, 47, 48, 49], [1, 2, 4, 6, 8, 9, 11, 13, 15, 16, 17, 18, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [2, 4, 8, 10, 12, 13, 14, 15, 17, 18, 19, 20, 21, 23, 25, 26, 27, 28, 29, 31, 32, 33, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [4, 6, 7, 11, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [1, 3, 6, 7, 8, 9, 10, 12, 13, 15, 17, 18, 19, 20, 21, 22, 24, 25, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [1, 3, 5, 7, 8, 9, 11, 14, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]],source = 4,target = 36) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]],source = 1,target = 50) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 21, 11, 31], [10, 20, 30, 40], [15, 25, 35, 45]],source = 1,target = 45) == 2\n assert candidate(routes = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [15, 25, 35, 45, 55, 65, 75, 85, 95, 105], [10, 25, 40, 55, 70, 85, 100, 115, 130, 145]],source = 10,target = 145) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]],source = 1,target = 100) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [1, 21, 30], [10, 20, 30]],source = 1,target = 30) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]],source = 1,target = 9) == 2\n assert candidate(routes = [[10, 11, 12, 13, 14, 15], [15, 16, 17, 18, 19, 20], [20, 21, 22, 23, 24, 25], [25, 26, 27, 28, 29, 30]],source = 10,target = 30) == 4\n assert candidate(routes = [[10, 20, 30], [20, 40, 50], [30, 50, 60], [60, 70, 80]],source = 10,target = 80) == 3\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [1, 11, 21], [2, 12, 22], [3, 13, 23], [4, 14, 24], [5, 15, 25], [6, 16, 26], [7, 17, 27], [8, 18, 28], [9, 19, 29], [10, 20, 30]],source = 1,target = 30) == 2\n assert candidate(routes = [[33, 22, 5, 13], [41, 33, 23, 32, 45, 35], [5, 6, 11, 15, 41, 47, 4, 19], [4, 31, 10, 48, 38, 16], [29, 38, 48, 18, 44, 35, 37, 42], [25, 22, 39, 43, 1, 26, 36, 28, 32, 30, 21], [12, 35, 29, 49, 11, 24], [47, 24, 40, 46, 42, 23, 41, 39, 34, 28], [26, 1, 34, 48, 49], [41, 26, 43, 20, 35, 30, 15, 37, 12], [11, 25, 39, 28, 10, 47, 21], [39, 18, 41, 19, 23, 26, 20, 11, 37, 33, 22, 34], [35, 18, 22, 40, 43, 27, 1, 37, 32, 20, 33], [32, 27, 28, 36, 43, 35, 24, 34, 39, 46, 42, 40, 37, 30, 31, 21, 15, 13, 4, 33, 19, 25, 10, 49, 23, 41, 12, 11, 47, 48], [4, 22, 18, 24, 40, 39, 26, 36, 43, 13, 11, 15, 28, 20, 37, 35, 33, 42, 47, 23, 30, 19, 1, 46, 34, 41, 49, 12, 31]],source = 1,target = 40) == 1\n assert candidate(routes = [[10, 20, 30, 40, 50], [60, 70, 80, 90, 100], [20, 80, 100], [50, 60, 70], [10, 50, 60, 70, 80, 90]],source = 10,target = 90) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]],source = 1,target = 17) == 2\n assert candidate(routes = [[1, 4, 6, 8, 10], [2, 5, 7, 9, 11], [3, 6, 9, 12, 15], [4, 7, 10, 13, 16], [5, 8, 11, 14, 17]],source = 1,target = 17) == 2\n assert candidate(routes = [[2, 5, 10], [8, 10, 11], [13, 14, 15], [1, 2, 5], [2, 6, 11], [3, 6, 13], [4, 5, 8, 14], [5, 6, 15]],source = 1,target = 15) == 2\n assert candidate(routes = [[1, 4, 5, 6], [2, 5, 7, 8], [3, 6, 8, 10], [4, 7, 9, 10], [5, 9, 11, 12], [6, 10, 12, 13], [7, 11, 13, 14], [8, 12, 14, 15]],source = 1,target = 15) == 3\n assert candidate(routes = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [9, 10, 11, 12, 13], [13, 14, 15, 16, 17], [17, 18, 19, 20, 21], [21, 1, 2, 3, 4], [4, 5, 6, 7, 8]],source = 1,target = 21) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40], [41, 42, 43, 44, 45], [46, 47, 48, 49, 50], [1, 6, 11, 16, 21, 26, 31, 36, 41, 46], [2, 7, 12, 17, 22, 27, 32, 37, 42, 47], [3, 8, 13, 18, 23, 28, 33, 38, 43, 48], [4, 9, 14, 19, 24, 29, 34, 39, 44, 49], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]],source = 1,target = 50) == 2\n assert candidate(routes = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [1, 11, 21, 31, 41, 51], [2, 12, 22, 32, 42, 52], [3, 13, 23, 33, 43, 53], [4, 14, 24, 34, 44, 54], [5, 15, 25, 35, 45, 55]],source = 1,target = 55) == -1\n assert candidate(routes = [[2, 7, 8, 9], [4, 7, 8, 11, 12, 13, 14, 17, 19, 20, 22, 23, 24, 26, 27, 30, 31, 32, 34, 35, 36, 37, 38, 40, 41, 42, 44, 45, 46, 48], [2, 3, 4, 6, 11, 12, 13, 16, 18, 19, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 40, 41, 42, 44, 46, 48, 49], [4, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [2, 3, 5, 6, 11, 12, 13, 14, 16, 18, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 40, 41, 42, 44, 45, 46, 48], [4, 7, 8, 11, 12, 13, 14, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [4, 7, 8, 11, 12, 13, 14, 15, 16, 18, 19, 20, 21, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 45, 46, 48], [4, 7, 8, 11, 12, 14, 15, 17, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [3, 4, 5, 6, 7, 8, 11, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [2, 3, 5, 7, 8, 9, 11, 12, 14, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]],source = 4,target = 34) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39], [39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58]],source = 1,target = 58) == 3\n assert candidate(routes = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9], [9, 10, 11], [11, 12, 13], [13, 14, 15], [15, 16, 17], [17, 18, 19], [19, 20, 21], [21, 22, 23], [23, 24, 25], [25, 26, 27], [27, 28, 29], [29, 30, 31], [31, 32, 33], [33, 34, 35], [35, 36, 37], [37, 38, 39], [39, 40, 41], [41, 42, 43], [43, 44, 45]],source = 1,target = 45) == 22\n assert candidate(routes = [[3, 7, 9, 11, 13, 15], [1, 3, 5, 7, 9, 11], [5, 11, 17, 23, 29], [7, 15, 21, 27, 33], [9, 13, 19, 25, 31], [11, 17, 23, 29, 35], [13, 21, 25, 29, 37], [15, 27, 35, 43, 47], [17, 29, 39, 49, 53], [19, 31, 41, 49, 57], [21, 25, 31, 43, 49], [23, 37, 43, 51, 57], [25, 29, 35, 43, 49, 53, 57]],source = 3,target = 47) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5], [5, 6, 7, 8, 9], [9, 10, 11, 12, 13], [13, 14, 15, 16, 17], [17, 18, 19, 20, 1]],source = 1,target = 20) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]],source = 1,target = 20) == -1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]],source = 1,target = 20) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [5, 10, 15, 20], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],source = 1,target = 20) == 2\n assert candidate(routes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]],source = 1,target = 55) == 2\n assert candidate(routes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [1, 11, 21, 31, 41, 51, 61, 71, 81, 91], [2, 12, 22, 32, 42, 52, 62, 72, 82, 92]],source = 1,target = 92) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [50, 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], [90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]],source = 1,target = 100) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],source = 1,target = 30) == -1\n assert candidate(routes = [[3, 11, 13, 19], [7, 11, 17], [9, 13, 18, 23], [10, 14, 19, 23], [12, 15, 17, 21], [13, 18, 20, 22], [14, 15, 19, 21], [16, 17, 22, 23], [18, 20, 23, 24], [20, 21, 22, 24]],source = 3,target = 24) == 3\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200, 205, 210, 215, 220, 225, 230, 235, 240, 245, 250]],source = 1,target = 250) == 2\n assert candidate(routes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],source = 1,target = 20) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5], [2, 6, 7, 8], [3, 9, 10, 11], [4, 12, 13, 14], [5, 6, 9, 12], [7, 10, 13, 15], [8, 11, 14, 16], [15, 16, 17, 18], [17, 18, 19, 20]],source = 1,target = 20) == 5\n assert candidate(routes = [[10, 20, 30, 40], [20, 50, 60], [30, 70, 80], [40, 50, 90], [60, 70, 100], [80, 90, 100]],source = 10,target = 100) == 3\n assert candidate(routes = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9], [9, 10, 1], [2, 4, 6], [8, 10, 12], [12, 14, 16], [16, 18, 20], [20, 1, 3]],source = 1,target = 20) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]],source = 1,target = 40) == -1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13]],source = 1,target = 13) == 2\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 11, 12, 13, 14, 15], [15, 16, 17, 18, 19, 20], [20, 21, 22, 23, 24, 25], [25, 26, 27, 28, 29, 30]],source = 1,target = 30) == 5\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [5, 10, 15, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],source = 1,target = 30) == -1\n assert candidate(routes = [[1, 10, 19], [2, 3, 10, 14], [4, 14, 16, 20], [11, 16, 18], [6, 7, 11, 18], [9, 15, 20]],source = 1,target = 20) == 3\n assert candidate(routes = [[1, 2, 3, 4, 5], [5, 6, 7, 8, 9], [9, 10, 11, 12, 13], [13, 14, 15, 16, 17], [17, 18, 19, 20, 1]],source = 1,target = 20) == 1\n assert candidate(routes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [1, 11, 21, 31], [2, 12, 22, 32], [3, 13, 23, 33], [4, 14, 24, 34], [5, 15, 25, 35], [6, 16, 26, 36], [7, 17, 27, 37], [8, 18, 28, 38], [9, 19, 29, 39], [10, 20, 30, 40]],source = 1,target = 40) == 2\n assert candidate(routes = [[1000, 2000], [2000, 3000, 4000], [4000, 5000, 6000], [6000, 7000, 8000], [8000, 9000, 10000], [10000, 11000], [11000, 12000, 13000], [13000, 14000], [14000, 15000, 1000]],source = 1000,target = 15000) == 1\n assert candidate(routes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22], [21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41], [41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61]],source = 1,target = 61) == 3\n", "comparison": "exact"}, "public_tests": ["[[1,2,7],[3,6,7]]\n1\n6", "[[7,12],[4,5,15],[6],[15,19],[9,12,13]]\n15\n12"], "hints": [], "metadata": {"canonical_parameter_names": ["routes", "source", "target"], "leetcode_dataset_entry_point": "Solution().numBusesToDestination", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:39+00:00", "tests_total": 77, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "breadth-first-search"]}, "language": "java", "interface": {"raw_signature": "public int numBusesToDestination(int[][] routes, int source, int target) {", "container": "Solution", "callable": "numBusesToDestination", "parameters": [{"name": "routes", "type": "int[][]"}, {"name": "source", "type": "int"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 816, "task_id": "ambiguous-coordinates", "difficulty": "Medium", "problem_description": "We had some 2-dimensional coordinates, like \"(1, 3)\" or \"(2, 0.5)\". Then, we removed all commas, decimal points, and spaces and ended up with the string s.\n\n- For example, \"(1, 3)\" becomes s = \"(13)\" and \"(2, 0.5)\" becomes s = \"(205)\".\n\nReturn a list of strings representing all possibilities for what our original coordinates could have been.\n\nOur original representation never had extraneous zeroes, so we never started with numbers like \"00\", \"0.0\", \"0.00\", \"1.0\", \"001\", \"00.01\", or any other number that can be represented with fewer digits. Also, a decimal point within a number never occurs without at least one digit occurring before it, so we never started with numbers like \".1\".\n\nThe final answer list can be returned in any order. All coordinates in the final answer have exactly one space between them (occurring after the comma.)\n\nExample 1:\n\nInput: s = \"(123)\"\nOutput: [\"(1, 2.3)\",\"(1, 23)\",\"(1.2, 3)\",\"(12, 3)\"]\n\nExample 2:\n\nInput: s = \"(0123)\"\nOutput: [\"(0, 1.23)\",\"(0, 12.3)\",\"(0, 123)\",\"(0.1, 2.3)\",\"(0.1, 23)\",\"(0.12, 3)\"]\nExplanation: 0.0, 00, 0001 or 00.01 are not allowed.\n\nExample 3:\n\nInput: s = \"(00011)\"\nOutput: [\"(0, 0.011)\",\"(0.001, 1)\"]\n\nConstraints:\n\n- 4 <= s.length <= 12\n- s[0] == '(' and s[s.length - 1] == ')'.\n- The rest of s are digits.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(s='(1001)'), ['(1, 0.01)', '(10, 0.1)', '(100, 1)'])\n assert answers_match(candidate(s='(12345)'), ['(1, 2.345)', '(1, 23.45)', '(1, 234.5)', '(1, 2345)', '(1.2, 3.45)', '(1.2, 34.5)', '(1.2, 345)', '(12, 3.45)', '(12, 34.5)', '(12, 345)', '(1.23, 4.5)', '(1.23, 45)', '(12.3, 4.5)', '(12.3, 45)', '(123, 4.5)', '(123, 45)', '(1.234, 5)', '(12.34, 5)', '(123.4, 5)', '(1234, 5)'])\n assert answers_match(candidate(s='(01001)'), ['(0, 1.001)', '(0, 10.01)', '(0, 100.1)', '(0, 1001)', '(0.1, 0.01)'])\n assert answers_match(candidate(s='(1010)'), ['(10, 10)', '(1.01, 0)', '(10.1, 0)', '(101, 0)'])\n assert answers_match(candidate(s='(1000)'), ['(100, 0)'])\n assert answers_match(candidate(s='(0123)'), ['(0, 1.23)', '(0, 12.3)', '(0, 123)', '(0.1, 2.3)', '(0.1, 23)', '(0.12, 3)'])\n assert answers_match(candidate(s='(00011)'), ['(0, 0.011)', '(0.001, 1)'])\n assert answers_match(candidate(s='(123)'), ['(1, 2.3)', '(1, 23)', '(1.2, 3)', '(12, 3)'])\n assert answers_match(candidate(s='(1234)'), ['(1, 2.34)', '(1, 23.4)', '(1, 234)', '(1.2, 3.4)', '(1.2, 34)', '(12, 3.4)', '(12, 34)', '(1.23, 4)', '(12.3, 4)', '(123, 4)'])\n assert answers_match(candidate(s='(100)'), ['(10, 0)'])\n assert answers_match(candidate(s='(110)'), ['(1, 10)', '(1.1, 0)', '(11, 0)'])\n assert answers_match(candidate(s='(10001)'), ['(1, 0.001)', '(10, 0.01)', '(100, 0.1)', '(1000, 1)'])\n assert answers_match(candidate(s='(0000)'), [])\n assert answers_match(candidate(s='(00100)'), [])\n assert answers_match(candidate(s='(00001)'), ['(0, 0.001)'])\n assert answers_match(candidate(s='(010)'), ['(0, 10)', '(0.1, 0)'])\n assert answers_match(candidate(s='(987654)'), ['(9, 8.7654)', '(9, 87.654)', '(9, 876.54)', '(9, 8765.4)', '(9, 87654)', '(9.8, 7.654)', '(9.8, 76.54)', '(9.8, 765.4)', '(9.8, 7654)', '(98, 7.654)', '(98, 76.54)', '(98, 765.4)', '(98, 7654)', '(9.87, 6.54)', '(9.87, 65.4)', '(9.87, 654)', '(98.7, 6.54)', '(98.7, 65.4)', '(98.7, 654)', '(987, 6.54)', '(987, 65.4)', '(987, 654)', '(9.876, 5.4)', '(9.876, 54)', '(98.76, 5.4)', '(98.76, 54)', '(987.6, 5.4)', '(987.6, 54)', '(9876, 5.4)', '(9876, 54)', '(9.8765, 4)', '(98.765, 4)', '(987.65, 4)', '(9876.5, 4)', '(98765, 4)'])\n assert answers_match(candidate(s='(00010001)'), ['(0, 0.010001)', '(0.001, 0.001)'])\n assert answers_match(candidate(s='(12340001)'), ['(1, 2.340001)', '(1, 23.40001)', '(1, 234.0001)', '(1, 2340.001)', '(1, 23400.01)', '(1, 234000.1)', '(1, 2340001)', '(1.2, 3.40001)', '(1.2, 34.0001)', '(1.2, 340.001)', '(1.2, 3400.01)', '(1.2, 34000.1)', '(1.2, 340001)', '(12, 3.40001)', '(12, 34.0001)', '(12, 340.001)', '(12, 3400.01)', '(12, 34000.1)', '(12, 340001)', '(1.23, 4.0001)', '(1.23, 40.001)', '(1.23, 400.01)', '(1.23, 4000.1)', '(1.23, 40001)', '(12.3, 4.0001)', '(12.3, 40.001)', '(12.3, 400.01)', '(12.3, 4000.1)', '(12.3, 40001)', '(123, 4.0001)', '(123, 40.001)', '(123, 400.01)', '(123, 4000.1)', '(123, 40001)', '(1.234, 0.001)', '(12.34, 0.001)', '(123.4, 0.001)', '(1234, 0.001)', '(12340, 0.01)', '(123400, 0.1)', '(1234000, 1)'])\n assert answers_match(candidate(s='(000100)'), [])\n assert answers_match(candidate(s='(12300123)'), ['(1, 2.300123)', '(1, 23.00123)', '(1, 230.0123)', '(1, 2300.123)', '(1, 23001.23)', '(1, 230012.3)', '(1, 2300123)', '(1.2, 3.00123)', '(1.2, 30.0123)', '(1.2, 300.123)', '(1.2, 3001.23)', '(1.2, 30012.3)', '(1.2, 300123)', '(12, 3.00123)', '(12, 30.0123)', '(12, 300.123)', '(12, 3001.23)', '(12, 30012.3)', '(12, 300123)', '(1.23, 0.0123)', '(12.3, 0.0123)', '(123, 0.0123)', '(1230, 0.123)', '(12300, 1.23)', '(12300, 12.3)', '(12300, 123)', '(1.23001, 2.3)', '(1.23001, 23)', '(12.3001, 2.3)', '(12.3001, 23)', '(123.001, 2.3)', '(123.001, 23)', '(1230.01, 2.3)', '(1230.01, 23)', '(12300.1, 2.3)', '(12300.1, 23)', '(123001, 2.3)', '(123001, 23)', '(1.230012, 3)', '(12.30012, 3)', '(123.0012, 3)', '(1230.012, 3)', '(12300.12, 3)', '(123001.2, 3)', '(1230012, 3)'])\n assert answers_match(candidate(s='(0010001)'), ['(0, 0.10001)', '(0.01, 0.001)'])\n assert answers_match(candidate(s='(1234567)'), ['(1, 2.34567)', '(1, 23.4567)', '(1, 234.567)', '(1, 2345.67)', '(1, 23456.7)', '(1, 234567)', '(1.2, 3.4567)', '(1.2, 34.567)', '(1.2, 345.67)', '(1.2, 3456.7)', '(1.2, 34567)', '(12, 3.4567)', '(12, 34.567)', '(12, 345.67)', '(12, 3456.7)', '(12, 34567)', '(1.23, 4.567)', '(1.23, 45.67)', '(1.23, 456.7)', '(1.23, 4567)', '(12.3, 4.567)', '(12.3, 45.67)', '(12.3, 456.7)', '(12.3, 4567)', '(123, 4.567)', '(123, 45.67)', '(123, 456.7)', '(123, 4567)', '(1.234, 5.67)', '(1.234, 56.7)', '(1.234, 567)', '(12.34, 5.67)', '(12.34, 56.7)', '(12.34, 567)', '(123.4, 5.67)', '(123.4, 56.7)', '(123.4, 567)', '(1234, 5.67)', '(1234, 56.7)', '(1234, 567)', '(1.2345, 6.7)', '(1.2345, 67)', '(12.345, 6.7)', '(12.345, 67)', '(123.45, 6.7)', '(123.45, 67)', '(1234.5, 6.7)', '(1234.5, 67)', '(12345, 6.7)', '(12345, 67)', '(1.23456, 7)', '(12.3456, 7)', '(123.456, 7)', '(1234.56, 7)', '(12345.6, 7)', '(123456, 7)'])\n assert answers_match(candidate(s='(987654321)'), ['(9, 8.7654321)', '(9, 87.654321)', '(9, 876.54321)', '(9, 8765.4321)', '(9, 87654.321)', '(9, 876543.21)', '(9, 8765432.1)', '(9, 87654321)', '(9.8, 7.654321)', '(9.8, 76.54321)', '(9.8, 765.4321)', '(9.8, 7654.321)', '(9.8, 76543.21)', '(9.8, 765432.1)', '(9.8, 7654321)', '(98, 7.654321)', '(98, 76.54321)', '(98, 765.4321)', '(98, 7654.321)', '(98, 76543.21)', '(98, 765432.1)', '(98, 7654321)', '(9.87, 6.54321)', '(9.87, 65.4321)', '(9.87, 654.321)', '(9.87, 6543.21)', '(9.87, 65432.1)', '(9.87, 654321)', '(98.7, 6.54321)', '(98.7, 65.4321)', '(98.7, 654.321)', '(98.7, 6543.21)', '(98.7, 65432.1)', '(98.7, 654321)', '(987, 6.54321)', '(987, 65.4321)', '(987, 654.321)', '(987, 6543.21)', '(987, 65432.1)', '(987, 654321)', '(9.876, 5.4321)', '(9.876, 54.321)', '(9.876, 543.21)', '(9.876, 5432.1)', '(9.876, 54321)', '(98.76, 5.4321)', '(98.76, 54.321)', '(98.76, 543.21)', '(98.76, 5432.1)', '(98.76, 54321)', '(987.6, 5.4321)', '(987.6, 54.321)', '(987.6, 543.21)', '(987.6, 5432.1)', '(987.6, 54321)', '(9876, 5.4321)', '(9876, 54.321)', '(9876, 543.21)', '(9876, 5432.1)', '(9876, 54321)', '(9.8765, 4.321)', '(9.8765, 43.21)', '(9.8765, 432.1)', '(9.8765, 4321)', '(98.765, 4.321)', '(98.765, 43.21)', '(98.765, 432.1)', '(98.765, 4321)', '(987.65, 4.321)', '(987.65, 43.21)', '(987.65, 432.1)', '(987.65, 4321)', '(9876.5, 4.321)', '(9876.5, 43.21)', '(9876.5, 432.1)', '(9876.5, 4321)', '(98765, 4.321)', '(98765, 43.21)', '(98765, 432.1)', '(98765, 4321)', '(9.87654, 3.21)', '(9.87654, 32.1)', '(9.87654, 321)', '(98.7654, 3.21)', '(98.7654, 32.1)', '(98.7654, 321)', '(987.654, 3.21)', '(987.654, 32.1)', '(987.654, 321)', '(9876.54, 3.21)', '(9876.54, 32.1)', '(9876.54, 321)', '(98765.4, 3.21)', '(98765.4, 32.1)', '(98765.4, 321)', '(987654, 3.21)', '(987654, 32.1)', '(987654, 321)', '(9.876543, 2.1)', '(9.876543, 21)', '(98.76543, 2.1)', '(98.76543, 21)', '(987.6543, 2.1)', '(987.6543, 21)', '(9876.543, 2.1)', '(9876.543, 21)', '(98765.43, 2.1)', '(98765.43, 21)', '(987654.3, 2.1)', '(987654.3, 21)', '(9876543, 2.1)', '(9876543, 21)', '(9.8765432, 1)', '(98.765432, 1)', '(987.65432, 1)', '(9876.5432, 1)', '(98765.432, 1)', '(987654.32, 1)', '(9876543.2, 1)', '(98765432, 1)'])\n assert answers_match(candidate(s='(000000)'), [])\n assert answers_match(candidate(s='(00000123)'), ['(0, 0.000123)', '(0.00001, 2.3)', '(0.00001, 23)', '(0.000012, 3)'])\n assert answers_match(candidate(s='(123050)'), ['(1, 23050)', '(1.2, 3050)', '(12, 3050)', '(1230, 50)', '(1.2305, 0)', '(12.305, 0)', '(123.05, 0)', '(1230.5, 0)', '(12305, 0)'])\n assert answers_match(candidate(s='(000123)'), ['(0, 0.0123)', '(0.001, 2.3)', '(0.001, 23)', '(0.0012, 3)'])\n assert answers_match(candidate(s='(0000000001)'), ['(0, 0.00000001)'])\n assert answers_match(candidate(s='(00012345)'), ['(0, 0.012345)', '(0.001, 2.345)', '(0.001, 23.45)', '(0.001, 234.5)', '(0.001, 2345)', '(0.0012, 3.45)', '(0.0012, 34.5)', '(0.0012, 345)', '(0.00123, 4.5)', '(0.00123, 45)', '(0.001234, 5)'])\n assert answers_match(candidate(s='(012301)'), ['(0, 1.2301)', '(0, 12.301)', '(0, 123.01)', '(0, 1230.1)', '(0, 12301)', '(0.1, 2.301)', '(0.1, 23.01)', '(0.1, 230.1)', '(0.1, 2301)', '(0.12, 3.01)', '(0.12, 30.1)', '(0.12, 301)', '(0.123, 0.1)'])\n assert answers_match(candidate(s='(123450123)'), ['(1, 2.3450123)', '(1, 23.450123)', '(1, 234.50123)', '(1, 2345.0123)', '(1, 23450.123)', '(1, 234501.23)', '(1, 2345012.3)', '(1, 23450123)', '(1.2, 3.450123)', '(1.2, 34.50123)', '(1.2, 345.0123)', '(1.2, 3450.123)', '(1.2, 34501.23)', '(1.2, 345012.3)', '(1.2, 3450123)', '(12, 3.450123)', '(12, 34.50123)', '(12, 345.0123)', '(12, 3450.123)', '(12, 34501.23)', '(12, 345012.3)', '(12, 3450123)', '(1.23, 4.50123)', '(1.23, 45.0123)', '(1.23, 450.123)', '(1.23, 4501.23)', '(1.23, 45012.3)', '(1.23, 450123)', '(12.3, 4.50123)', '(12.3, 45.0123)', '(12.3, 450.123)', '(12.3, 4501.23)', '(12.3, 45012.3)', '(12.3, 450123)', '(123, 4.50123)', '(123, 45.0123)', '(123, 450.123)', '(123, 4501.23)', '(123, 45012.3)', '(123, 450123)', '(1.234, 5.0123)', '(1.234, 50.123)', '(1.234, 501.23)', '(1.234, 5012.3)', '(1.234, 50123)', '(12.34, 5.0123)', '(12.34, 50.123)', '(12.34, 501.23)', '(12.34, 5012.3)', '(12.34, 50123)', '(123.4, 5.0123)', '(123.4, 50.123)', '(123.4, 501.23)', '(123.4, 5012.3)', '(123.4, 50123)', '(1234, 5.0123)', '(1234, 50.123)', '(1234, 501.23)', '(1234, 5012.3)', '(1234, 50123)', '(1.2345, 0.123)', '(12.345, 0.123)', '(123.45, 0.123)', '(1234.5, 0.123)', '(12345, 0.123)', '(123450, 1.23)', '(123450, 12.3)', '(123450, 123)', '(1.234501, 2.3)', '(1.234501, 23)', '(12.34501, 2.3)', '(12.34501, 23)', '(123.4501, 2.3)', '(123.4501, 23)', '(1234.501, 2.3)', '(1234.501, 23)', '(12345.01, 2.3)', '(12345.01, 23)', '(123450.1, 2.3)', '(123450.1, 23)', '(1234501, 2.3)', '(1234501, 23)', '(1.2345012, 3)', '(12.345012, 3)', '(123.45012, 3)', '(1234.5012, 3)', '(12345.012, 3)', '(123450.12, 3)', '(1234501.2, 3)', '(12345012, 3)'])\n assert answers_match(candidate(s='(010101)'), ['(0, 1.0101)', '(0, 10.101)', '(0, 101.01)', '(0, 1010.1)', '(0, 10101)', '(0.1, 0.101)', '(0.101, 0.1)'])\n assert answers_match(candidate(s='(0001234)'), ['(0, 0.01234)', '(0.001, 2.34)', '(0.001, 23.4)', '(0.001, 234)', '(0.0012, 3.4)', '(0.0012, 34)', '(0.00123, 4)'])\n assert answers_match(candidate(s='(00012340)'), ['(0.001, 2340)', '(0.0012, 340)', '(0.00123, 40)', '(0.001234, 0)'])\n assert answers_match(candidate(s='(0000001)'), ['(0, 0.00001)'])\n assert answers_match(candidate(s='(10000010)'), ['(100000, 10)', '(1.000001, 0)', '(10.00001, 0)', '(100.0001, 0)', '(1000.001, 0)', '(10000.01, 0)', '(100000.1, 0)', '(1000001, 0)'])\n assert answers_match(candidate(s='(12012012)'), ['(1, 2.012012)', '(1, 20.12012)', '(1, 201.2012)', '(1, 2012.012)', '(1, 20120.12)', '(1, 201201.2)', '(1, 2012012)', '(1.2, 0.12012)', '(12, 0.12012)', '(120, 1.2012)', '(120, 12.012)', '(120, 120.12)', '(120, 1201.2)', '(120, 12012)', '(1.201, 2.012)', '(1.201, 20.12)', '(1.201, 201.2)', '(1.201, 2012)', '(12.01, 2.012)', '(12.01, 20.12)', '(12.01, 201.2)', '(12.01, 2012)', '(120.1, 2.012)', '(120.1, 20.12)', '(120.1, 201.2)', '(120.1, 2012)', '(1201, 2.012)', '(1201, 20.12)', '(1201, 201.2)', '(1201, 2012)', '(1.2012, 0.12)', '(12.012, 0.12)', '(120.12, 0.12)', '(1201.2, 0.12)', '(12012, 0.12)', '(120120, 1.2)', '(120120, 12)', '(1.201201, 2)', '(12.01201, 2)', '(120.1201, 2)', '(1201.201, 2)', '(12012.01, 2)', '(120120.1, 2)', '(1201201, 2)'])\n assert answers_match(candidate(s='(001203)'), ['(0, 0.1203)', '(0.01, 2.03)', '(0.01, 20.3)', '(0.01, 203)', '(0.012, 0.3)'])\n assert answers_match(candidate(s='(000010001)'), ['(0, 0.0010001)', '(0.0001, 0.001)'])\n assert answers_match(candidate(s='(100001)'), ['(1, 0.0001)', '(10, 0.001)', '(100, 0.01)', '(1000, 0.1)', '(10000, 1)'])\n assert answers_match(candidate(s='(01230123)'), ['(0, 1.230123)', '(0, 12.30123)', '(0, 123.0123)', '(0, 1230.123)', '(0, 12301.23)', '(0, 123012.3)', '(0, 1230123)', '(0.1, 2.30123)', '(0.1, 23.0123)', '(0.1, 230.123)', '(0.1, 2301.23)', '(0.1, 23012.3)', '(0.1, 230123)', '(0.12, 3.0123)', '(0.12, 30.123)', '(0.12, 301.23)', '(0.12, 3012.3)', '(0.12, 30123)', '(0.123, 0.123)', '(0.12301, 2.3)', '(0.12301, 23)', '(0.123012, 3)'])\n assert answers_match(candidate(s='(1000000)'), ['(100000, 0)'])\n assert answers_match(candidate(s='(0001000100)'), [])\n assert answers_match(candidate(s='(120030)'), ['(1, 20030)', '(1200, 30)', '(1.2003, 0)', '(12.003, 0)', '(120.03, 0)', '(1200.3, 0)', '(12003, 0)'])\n assert answers_match(candidate(s='(001001)'), ['(0, 0.1001)', '(0.01, 0.01)'])\n assert answers_match(candidate(s='(100000001)'), ['(1, 0.0000001)', '(10, 0.000001)', '(100, 0.00001)', '(1000, 0.0001)', '(10000, 0.001)', '(100000, 0.01)', '(1000000, 0.1)', '(10000000, 1)'])\n assert answers_match(candidate(s='(000000001)'), ['(0, 0.0000001)'])\n assert answers_match(candidate(s='(001234056)'), ['(0, 0.1234056)', '(0.01, 2.34056)', '(0.01, 23.4056)', '(0.01, 234.056)', '(0.01, 2340.56)', '(0.01, 23405.6)', '(0.01, 234056)', '(0.012, 3.4056)', '(0.012, 34.056)', '(0.012, 340.56)', '(0.012, 3405.6)', '(0.012, 34056)', '(0.0123, 4.056)', '(0.0123, 40.56)', '(0.0123, 405.6)', '(0.0123, 4056)', '(0.01234, 0.56)', '(0.0123405, 6)'])\n assert answers_match(candidate(s='(100100)'), ['(100, 100)', '(10010, 0)'])\n assert answers_match(candidate(s='(12345678)'), ['(1, 2.345678)', '(1, 23.45678)', '(1, 234.5678)', '(1, 2345.678)', '(1, 23456.78)', '(1, 234567.8)', '(1, 2345678)', '(1.2, 3.45678)', '(1.2, 34.5678)', '(1.2, 345.678)', '(1.2, 3456.78)', '(1.2, 34567.8)', '(1.2, 345678)', '(12, 3.45678)', '(12, 34.5678)', '(12, 345.678)', '(12, 3456.78)', '(12, 34567.8)', '(12, 345678)', '(1.23, 4.5678)', '(1.23, 45.678)', '(1.23, 456.78)', '(1.23, 4567.8)', '(1.23, 45678)', '(12.3, 4.5678)', '(12.3, 45.678)', '(12.3, 456.78)', '(12.3, 4567.8)', '(12.3, 45678)', '(123, 4.5678)', '(123, 45.678)', '(123, 456.78)', '(123, 4567.8)', '(123, 45678)', '(1.234, 5.678)', '(1.234, 56.78)', '(1.234, 567.8)', '(1.234, 5678)', '(12.34, 5.678)', '(12.34, 56.78)', '(12.34, 567.8)', '(12.34, 5678)', '(123.4, 5.678)', '(123.4, 56.78)', '(123.4, 567.8)', '(123.4, 5678)', '(1234, 5.678)', '(1234, 56.78)', '(1234, 567.8)', '(1234, 5678)', '(1.2345, 6.78)', '(1.2345, 67.8)', '(1.2345, 678)', '(12.345, 6.78)', '(12.345, 67.8)', '(12.345, 678)', '(123.45, 6.78)', '(123.45, 67.8)', '(123.45, 678)', '(1234.5, 6.78)', '(1234.5, 67.8)', '(1234.5, 678)', '(12345, 6.78)', '(12345, 67.8)', '(12345, 678)', '(1.23456, 7.8)', '(1.23456, 78)', '(12.3456, 7.8)', '(12.3456, 78)', '(123.456, 7.8)', '(123.456, 78)', '(1234.56, 7.8)', '(1234.56, 78)', '(12345.6, 7.8)', '(12345.6, 78)', '(123456, 7.8)', '(123456, 78)', '(1.234567, 8)', '(12.34567, 8)', '(123.4567, 8)', '(1234.567, 8)', '(12345.67, 8)', '(123456.7, 8)', '(1234567, 8)'])\n assert answers_match(candidate(s='(01001001)'), ['(0, 1.001001)', '(0, 10.01001)', '(0, 100.1001)', '(0, 1001.001)', '(0, 10010.01)', '(0, 100100.1)', '(0, 1001001)', '(0.1, 0.01001)', '(0.1001, 0.01)'])\n assert answers_match(candidate(s='(100100100)'), ['(100, 100100)', '(100100, 100)', '(10010010, 0)'])\n assert answers_match(candidate(s='(120000)'), ['(1, 20000)', '(12000, 0)'])\n assert answers_match(candidate(s='(10010)'), ['(100, 10)', '(1.001, 0)', '(10.01, 0)', '(100.1, 0)', '(1001, 0)'])\n assert answers_match(candidate(s='(123456)'), ['(1, 2.3456)', '(1, 23.456)', '(1, 234.56)', '(1, 2345.6)', '(1, 23456)', '(1.2, 3.456)', '(1.2, 34.56)', '(1.2, 345.6)', '(1.2, 3456)', '(12, 3.456)', '(12, 34.56)', '(12, 345.6)', '(12, 3456)', '(1.23, 4.56)', '(1.23, 45.6)', '(1.23, 456)', '(12.3, 4.56)', '(12.3, 45.6)', '(12.3, 456)', '(123, 4.56)', '(123, 45.6)', '(123, 456)', '(1.234, 5.6)', '(1.234, 56)', '(12.34, 5.6)', '(12.34, 56)', '(123.4, 5.6)', '(123.4, 56)', '(1234, 5.6)', '(1234, 56)', '(1.2345, 6)', '(12.345, 6)', '(123.45, 6)', '(1234.5, 6)', '(12345, 6)'])\n assert answers_match(candidate(s='(01000100)'), ['(0, 1000100)'])\n assert answers_match(candidate(s='(0120304)'), ['(0, 1.20304)', '(0, 12.0304)', '(0, 120.304)', '(0, 1203.04)', '(0, 12030.4)', '(0, 120304)', '(0.1, 2.0304)', '(0.1, 20.304)', '(0.1, 203.04)', '(0.1, 2030.4)', '(0.1, 20304)', '(0.12, 0.304)', '(0.1203, 0.4)'])\n assert answers_match(candidate(s='(001234567)'), ['(0, 0.1234567)', '(0.01, 2.34567)', '(0.01, 23.4567)', '(0.01, 234.567)', '(0.01, 2345.67)', '(0.01, 23456.7)', '(0.01, 234567)', '(0.012, 3.4567)', '(0.012, 34.567)', '(0.012, 345.67)', '(0.012, 3456.7)', '(0.012, 34567)', '(0.0123, 4.567)', '(0.0123, 45.67)', '(0.0123, 456.7)', '(0.0123, 4567)', '(0.01234, 5.67)', '(0.01234, 56.7)', '(0.01234, 567)', '(0.012345, 6.7)', '(0.012345, 67)', '(0.0123456, 7)'])\n assert answers_match(candidate(s='(9876543210)'), ['(9, 876543210)', '(9.8, 76543210)', '(98, 76543210)', '(9.87, 6543210)', '(98.7, 6543210)', '(987, 6543210)', '(9.876, 543210)', '(98.76, 543210)', '(987.6, 543210)', '(9876, 543210)', '(9.8765, 43210)', '(98.765, 43210)', '(987.65, 43210)', '(9876.5, 43210)', '(98765, 43210)', '(9.87654, 3210)', '(98.7654, 3210)', '(987.654, 3210)', '(9876.54, 3210)', '(98765.4, 3210)', '(987654, 3210)', '(9.876543, 210)', '(98.76543, 210)', '(987.6543, 210)', '(9876.543, 210)', '(98765.43, 210)', '(987654.3, 210)', '(9876543, 210)', '(9.8765432, 10)', '(98.765432, 10)', '(987.65432, 10)', '(9876.5432, 10)', '(98765.432, 10)', '(987654.32, 10)', '(9876543.2, 10)', '(98765432, 10)', '(9.87654321, 0)', '(98.7654321, 0)', '(987.654321, 0)', '(9876.54321, 0)', '(98765.4321, 0)', '(987654.321, 0)', '(9876543.21, 0)', '(98765432.1, 0)', '(987654321, 0)'])\n assert answers_match(candidate(s='(1230000000)'), ['(1, 230000000)', '(1.2, 30000000)', '(12, 30000000)', '(123000000, 0)'])\n assert answers_match(candidate(s='(0123456789)'), ['(0, 1.23456789)', '(0, 12.3456789)', '(0, 123.456789)', '(0, 1234.56789)', '(0, 12345.6789)', '(0, 123456.789)', '(0, 1234567.89)', '(0, 12345678.9)', '(0, 123456789)', '(0.1, 2.3456789)', '(0.1, 23.456789)', '(0.1, 234.56789)', '(0.1, 2345.6789)', '(0.1, 23456.789)', '(0.1, 234567.89)', '(0.1, 2345678.9)', '(0.1, 23456789)', '(0.12, 3.456789)', '(0.12, 34.56789)', '(0.12, 345.6789)', '(0.12, 3456.789)', '(0.12, 34567.89)', '(0.12, 345678.9)', '(0.12, 3456789)', '(0.123, 4.56789)', '(0.123, 45.6789)', '(0.123, 456.789)', '(0.123, 4567.89)', '(0.123, 45678.9)', '(0.123, 456789)', '(0.1234, 5.6789)', '(0.1234, 56.789)', '(0.1234, 567.89)', '(0.1234, 5678.9)', '(0.1234, 56789)', '(0.12345, 6.789)', '(0.12345, 67.89)', '(0.12345, 678.9)', '(0.12345, 6789)', '(0.123456, 7.89)', '(0.123456, 78.9)', '(0.123456, 789)', '(0.1234567, 8.9)', '(0.1234567, 89)', '(0.12345678, 9)'])\n assert answers_match(candidate(s='(010010)'), ['(0, 10010)', '(0.1001, 0)'])\n assert answers_match(candidate(s='(0001230456)'), ['(0, 0.01230456)', '(0.001, 2.30456)', '(0.001, 23.0456)', '(0.001, 230.456)', '(0.001, 2304.56)', '(0.001, 23045.6)', '(0.001, 230456)', '(0.0012, 3.0456)', '(0.0012, 30.456)', '(0.0012, 304.56)', '(0.0012, 3045.6)', '(0.0012, 30456)', '(0.00123, 0.456)', '(0.0012304, 5.6)', '(0.0012304, 56)', '(0.00123045, 6)'])\n assert answers_match(candidate(s='(0101010)'), ['(0, 101010)', '(0.10101, 0)'])\n assert answers_match(candidate(s='(123450000)'), ['(1, 23450000)', '(1.2, 3450000)', '(12, 3450000)', '(1.23, 450000)', '(12.3, 450000)', '(123, 450000)', '(1.234, 50000)', '(12.34, 50000)', '(123.4, 50000)', '(1234, 50000)', '(12345000, 0)'])\n assert answers_match(candidate(s='(1230000)'), ['(1, 230000)', '(1.2, 30000)', '(12, 30000)', '(123000, 0)'])\n assert answers_match(candidate(s='(1001001001)'), ['(1, 0.01001001)', '(10, 0.1001001)', '(100, 1.001001)', '(100, 10.01001)', '(100, 100.1001)', '(100, 1001.001)', '(100, 10010.01)', '(100, 100100.1)', '(100, 1001001)', '(1.001, 0.01001)', '(10.01, 0.01001)', '(100.1, 0.01001)', '(1001, 0.01001)', '(10010, 0.1001)', '(100100, 1.001)', '(100100, 10.01)', '(100100, 100.1)', '(100100, 1001)', '(1.001001, 0.01)', '(10.01001, 0.01)', '(100.1001, 0.01)', '(1001.001, 0.01)', '(10010.01, 0.01)', '(100100.1, 0.01)', '(1001001, 0.01)', '(10010010, 0.1)', '(100100100, 1)'])\n assert answers_match(candidate(s='(100010100)'), ['(1000, 10100)', '(100010, 100)', '(10001010, 0)'])\n assert answers_match(candidate(s='(123456789)'), ['(1, 2.3456789)', '(1, 23.456789)', '(1, 234.56789)', '(1, 2345.6789)', '(1, 23456.789)', '(1, 234567.89)', '(1, 2345678.9)', '(1, 23456789)', '(1.2, 3.456789)', '(1.2, 34.56789)', '(1.2, 345.6789)', '(1.2, 3456.789)', '(1.2, 34567.89)', '(1.2, 345678.9)', '(1.2, 3456789)', '(12, 3.456789)', '(12, 34.56789)', '(12, 345.6789)', '(12, 3456.789)', '(12, 34567.89)', '(12, 345678.9)', '(12, 3456789)', '(1.23, 4.56789)', '(1.23, 45.6789)', '(1.23, 456.789)', '(1.23, 4567.89)', '(1.23, 45678.9)', '(1.23, 456789)', '(12.3, 4.56789)', '(12.3, 45.6789)', '(12.3, 456.789)', '(12.3, 4567.89)', '(12.3, 45678.9)', '(12.3, 456789)', '(123, 4.56789)', '(123, 45.6789)', '(123, 456.789)', '(123, 4567.89)', '(123, 45678.9)', '(123, 456789)', '(1.234, 5.6789)', '(1.234, 56.789)', '(1.234, 567.89)', '(1.234, 5678.9)', '(1.234, 56789)', '(12.34, 5.6789)', '(12.34, 56.789)', '(12.34, 567.89)', '(12.34, 5678.9)', '(12.34, 56789)', '(123.4, 5.6789)', '(123.4, 56.789)', '(123.4, 567.89)', '(123.4, 5678.9)', '(123.4, 56789)', '(1234, 5.6789)', '(1234, 56.789)', '(1234, 567.89)', '(1234, 5678.9)', '(1234, 56789)', '(1.2345, 6.789)', '(1.2345, 67.89)', '(1.2345, 678.9)', '(1.2345, 6789)', '(12.345, 6.789)', '(12.345, 67.89)', '(12.345, 678.9)', '(12.345, 6789)', '(123.45, 6.789)', '(123.45, 67.89)', '(123.45, 678.9)', '(123.45, 6789)', '(1234.5, 6.789)', '(1234.5, 67.89)', '(1234.5, 678.9)', '(1234.5, 6789)', '(12345, 6.789)', '(12345, 67.89)', '(12345, 678.9)', '(12345, 6789)', '(1.23456, 7.89)', '(1.23456, 78.9)', '(1.23456, 789)', '(12.3456, 7.89)', '(12.3456, 78.9)', '(12.3456, 789)', '(123.456, 7.89)', '(123.456, 78.9)', '(123.456, 789)', '(1234.56, 7.89)', '(1234.56, 78.9)', '(1234.56, 789)', '(12345.6, 7.89)', '(12345.6, 78.9)', '(12345.6, 789)', '(123456, 7.89)', '(123456, 78.9)', '(123456, 789)', '(1.234567, 8.9)', '(1.234567, 89)', '(12.34567, 8.9)', '(12.34567, 89)', '(123.4567, 8.9)', '(123.4567, 89)', '(1234.567, 8.9)', '(1234.567, 89)', '(12345.67, 8.9)', '(12345.67, 89)', '(123456.7, 8.9)', '(123456.7, 89)', '(1234567, 8.9)', '(1234567, 89)', '(1.2345678, 9)', '(12.345678, 9)', '(123.45678, 9)', '(1234.5678, 9)', '(12345.678, 9)', '(123456.78, 9)', '(1234567.8, 9)', '(12345678, 9)'])\n assert answers_match(candidate(s='(001001001)'), ['(0, 0.1001001)', '(0.01, 0.01001)', '(0.01001, 0.01)'])\n assert answers_match(candidate(s='(001234)'), ['(0, 0.1234)', '(0.01, 2.34)', '(0.01, 23.4)', '(0.01, 234)', '(0.012, 3.4)', '(0.012, 34)', '(0.0123, 4)'])\n assert answers_match(candidate(s='(1230456)'), ['(1, 2.30456)', '(1, 23.0456)', '(1, 230.456)', '(1, 2304.56)', '(1, 23045.6)', '(1, 230456)', '(1.2, 3.0456)', '(1.2, 30.456)', '(1.2, 304.56)', '(1.2, 3045.6)', '(1.2, 30456)', '(12, 3.0456)', '(12, 30.456)', '(12, 304.56)', '(12, 3045.6)', '(12, 30456)', '(1.23, 0.456)', '(12.3, 0.456)', '(123, 0.456)', '(1230, 4.56)', '(1230, 45.6)', '(1230, 456)', '(1.2304, 5.6)', '(1.2304, 56)', '(12.304, 5.6)', '(12.304, 56)', '(123.04, 5.6)', '(123.04, 56)', '(1230.4, 5.6)', '(1230.4, 56)', '(12304, 5.6)', '(12304, 56)', '(1.23045, 6)', '(12.3045, 6)', '(123.045, 6)', '(1230.45, 6)', '(12304.5, 6)', '(123045, 6)'])\n assert answers_match(candidate(s='(1001001)'), ['(1, 0.01001)', '(10, 0.1001)', '(100, 1.001)', '(100, 10.01)', '(100, 100.1)', '(100, 1001)', '(1.001, 0.01)', '(10.01, 0.01)', '(100.1, 0.01)', '(1001, 0.01)', '(10010, 0.1)', '(100100, 1)'])\n assert answers_match(candidate(s='(101010)'), ['(10, 1010)', '(1010, 10)', '(1.0101, 0)', '(10.101, 0)', '(101.01, 0)', '(1010.1, 0)', '(10101, 0)'])\n assert answers_match(candidate(s='(1111111)'), ['(1, 1.11111)', '(1, 11.1111)', '(1, 111.111)', '(1, 1111.11)', '(1, 11111.1)', '(1, 111111)', '(1.1, 1.1111)', '(1.1, 11.111)', '(1.1, 111.11)', '(1.1, 1111.1)', '(1.1, 11111)', '(11, 1.1111)', '(11, 11.111)', '(11, 111.11)', '(11, 1111.1)', '(11, 11111)', '(1.11, 1.111)', '(1.11, 11.11)', '(1.11, 111.1)', '(1.11, 1111)', '(11.1, 1.111)', '(11.1, 11.11)', '(11.1, 111.1)', '(11.1, 1111)', '(111, 1.111)', '(111, 11.11)', '(111, 111.1)', '(111, 1111)', '(1.111, 1.11)', '(1.111, 11.1)', '(1.111, 111)', '(11.11, 1.11)', '(11.11, 11.1)', '(11.11, 111)', '(111.1, 1.11)', '(111.1, 11.1)', '(111.1, 111)', '(1111, 1.11)', '(1111, 11.1)', '(1111, 111)', '(1.1111, 1.1)', '(1.1111, 11)', '(11.111, 1.1)', '(11.111, 11)', '(111.11, 1.1)', '(111.11, 11)', '(1111.1, 1.1)', '(1111.1, 11)', '(11111, 1.1)', '(11111, 11)', '(1.11111, 1)', '(11.1111, 1)', '(111.111, 1)', '(1111.11, 1)', '(11111.1, 1)', '(111111, 1)'])\n assert answers_match(candidate(s='(123000)'), ['(1, 23000)', '(1.2, 3000)', '(12, 3000)', '(12300, 0)'])\n assert answers_match(candidate(s='(1000000000)'), ['(100000000, 0)'])\n", "comparison": "unordered"}, "public_tests": ["\"(123)\"", "\"(0123)\"", "\"(00011)\""], "hints": [], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().ambiguousCoordinates", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:41+00:00", "tests_total": 93, "tests_dropped": 15, "flags": ["any_order"], "topic_tags": ["string", "backtracking", "enumeration"]}, "language": "java", "interface": {"raw_signature": "public List ambiguousCoordinates(String s) {", "container": "Solution", "callable": "ambiguousCoordinates", "parameters": [{"name": "s", "type": "String"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} @@ -43,7 +43,7 @@ {"question_id": 833, "task_id": "find-and-replace-in-string", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string s that you must perform k replacement operations on. The replacement operations are given as three 0-indexed parallel arrays, indices, sources, and targets, all of length k.\n\nTo complete the i^th replacement operation:\n\n1. Check if the substring sources[i] occurs at index indices[i] in the original string s.\n2. If it does not occur, do nothing.\n3. Otherwise if it does occur, replace that substring with targets[i].\n\nFor example, if s = \"abcd\", indices[i] = 0, sources[i] = \"ab\", and targets[i] = \"eee\", then the result of this replacement will be \"eeecd\".\n\nAll replacement operations must occur simultaneously, meaning the replacement operations should not affect the indexing of each other. The testcases will be generated such that the replacements will not overlap.\n\n- For example, a testcase with s = \"abc\", indices = [0, 1], and sources = [\"ab\",\"bc\"] will not be generated because the \"ab\" and \"bc\" replacements overlap.\n\nReturn the resulting string after performing all replacement operations on s.\n\nA substring is a contiguous sequence of characters in a string.\n\nExample 1:\n\nInput: s = \"abcd\", indices = [0, 2], sources = [\"a\", \"cd\"], targets = [\"eee\", \"ffff\"]\nOutput: \"eeebffff\"\nExplanation:\n\"a\" occurs at index 0 in s, so we replace it with \"eee\".\n\"cd\" occurs at index 2 in s, so we replace it with \"ffff\".\n\nExample 2:\n\nInput: s = \"abcd\", indices = [0, 2], sources = [\"ab\",\"ec\"], targets = [\"eee\",\"ffff\"]\nOutput: \"eeecd\"\nExplanation:\n\"ab\" occurs at index 0 in s, so we replace it with \"eee\".\n\"ec\" does not occur at index 2 in s, so we do nothing.\n\nConstraints:\n\n- 1 <= s.length <= 1000\n- k == indices.length == sources.length == targets.length\n- 1 <= k <= 100\n- 0 <= indexes[i] < s.length\n- 1 <= sources[i].length, targets[i].length <= 50\n- s consists of only lowercase English letters.\n- sources[i] and targets[i] consist of only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcd\",indices = [0, 2],sources = ['a', 'cd'],targets = ['eee', 'ffff']) == \"eeebffff\"\n assert candidate(s = \"abcd\",indices = [0, 1, 2, 3],sources = ['a', 'b', 'c', 'd'],targets = ['aa', 'bb', 'cc', 'dd']) == \"aabbccdd\"\n assert candidate(s = \"abcd\",indices = [0, 2],sources = ['ab', 'ec'],targets = ['eee', 'ffff']) == \"eeecd\"\n assert candidate(s = \"vmokgggqzp\",indices = [3, 5, 1],sources = ['kg', 'gggg', 'mo'],targets = ['s', 'so', 'bfr']) == \"vbfrsggqzp\"\n assert candidate(s = \"hello\",indices = [1, 4],sources = ['el', 'o'],targets = ['ll', 'oo']) == \"hllloo\"\n assert candidate(s = \"aaaaabbbbb\",indices = [0, 5],sources = ['aaaaa', 'bbbbb'],targets = ['z', 'y']) == \"zy\"\n assert candidate(s = \"mississippi\",indices = [0, 4, 10],sources = ['mis', 'issi', 'i'],targets = ['xxx', 'yyy', 'zzz']) == \"xxxsyyyppzzz\"\n assert candidate(s = \"abababab\",indices = [0, 2, 4, 6],sources = ['ab', 'ab', 'ab', 'ab'],targets = ['xy', 'yz', 'zx', 'wv']) == \"xyyzzxwv\"\n assert candidate(s = \"ababababab\",indices = [0, 2, 4, 6, 8],sources = ['ab', 'ab', 'ab', 'ab', 'ab'],targets = ['xy', 'yx', 'xy', 'yx', 'xy']) == \"xyyxxyyxxy\"\n assert candidate(s = \"hellothere\",indices = [0, 5],sources = ['he', 'th'],targets = ['hola', 'allahuakbar']) == \"holalloallahuakbarere\"\n assert candidate(s = \"ababababab\",indices = [0, 2, 4, 6, 8],sources = ['ab', 'ab', 'ab', 'ab', 'ab'],targets = ['xy', 'xy', 'xy', 'xy', 'xy']) == \"xyxyxyxyxy\"\n assert candidate(s = \"mississippi\",indices = [0, 4, 6],sources = ['mis', 'sis', 'sip'],targets = ['miss', 'sis', 'sip']) == \"misssissippi\"\n assert candidate(s = \"ababab\",indices = [0, 2, 4],sources = ['ab', 'ab', 'ab'],targets = ['xy', 'yz', 'zx']) == \"xyyzzx\"\n assert candidate(s = \"hellothere\",indices = [0, 5],sources = ['hello', 'there'],targets = ['hi', 'bye']) == \"hibye\"\n assert candidate(s = \"aaaaaa\",indices = [0, 1, 2, 3, 4, 5],sources = ['a', 'a', 'a', 'a', 'a', 'a'],targets = ['b', 'c', 'd', 'e', 'f', 'g']) == \"bcdefg\"\n assert candidate(s = \"xxxyyyzzz\",indices = [0, 3, 6],sources = ['xxx', 'yyy', 'zzz'],targets = ['aaa', 'bbb', 'ccc']) == \"aaabbbccc\"\n assert candidate(s = \"thisisatest\",indices = [0, 2, 4, 6, 8, 10],sources = ['this', 'is', 'a', 'test', 'xx', 'xx'],targets = ['that', 'was', 'the', 'exam', 'yy', 'zz']) == \"thatisatest\"\n assert candidate(s = \"hellohellohello\",indices = [0, 5, 10],sources = ['hello', 'hello', 'hello'],targets = ['hi', 'ho', 'ha']) == \"hihoha\"\n assert candidate(s = \"mississippi\",indices = [1, 4, 7],sources = ['is', 'is', 'is'],targets = ['aa', 'bb', 'cc']) == \"maasbbsippi\"\n assert candidate(s = \"mississippi\",indices = [0, 4, 8],sources = ['mis', 'iss', 'ippi'],targets = ['misss', 'issii', 'ipppi']) == \"missssissiiippi\"\n assert candidate(s = \"hellothere\",indices = [0, 5],sources = ['hello', 'there'],targets = ['hi', 'world']) == \"hiworld\"\n assert candidate(s = \"banana\",indices = [0, 2, 4],sources = ['ba', 'na', 'na'],targets = ['xx', 'yy', 'zz']) == \"xxyyzz\"\n assert candidate(s = \"banana\",indices = [1, 3],sources = ['an', 'na'],targets = ['xx', 'yy']) == \"bxxana\"\n assert candidate(s = \"abracadabra\",indices = [0, 5, 7],sources = ['abra', 'a', 'abra'],targets = ['zzzz', 'x', 'yyyy']) == \"zzzzcxdyyyy\"\n assert candidate(s = \"programmingisfun\",indices = [3, 10, 15],sources = ['gram', 'is', 'fun'],targets = ['code', 'was', 'great']) == \"procodemingisfun\"\n assert candidate(s = \"abcdefg\",indices = [0, 3, 5],sources = ['abc', 'de', 'fg'],targets = ['xyz', 'qrs', 'tuv']) == \"xyzqrstuv\"\n", "comparison": "exact"}, "public_tests": ["\"abcd\"\n[0, 2]\n[\"a\", \"cd\"]\n[\"eee\", \"ffff\"]", "\"abcd\"\n[0, 2]\n[\"ab\",\"ec\"]\n[\"eee\",\"ffff\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["s", "indices", "sources", "targets"], "leetcode_dataset_entry_point": "Solution().findReplaceString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:19+00:00", "tests_total": 96, "tests_dropped": 70, "flags": ["has_images"], "topic_tags": ["array", "hash-table", "string", "sorting"]}, "language": "java", "interface": {"raw_signature": "public String findReplaceString(String s, int[] indices, String[] sources, String[] targets) {", "container": "Solution", "callable": "findReplaceString", "parameters": [{"name": "s", "type": "String"}, {"name": "indices", "type": "int[]"}, {"name": "sources", "type": "String[]"}, {"name": "targets", "type": "String[]"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 834, "task_id": "sum-of-distances-in-tree", "difficulty": "Hard", "problem_description": "There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.\n\nYou are given the integer n and the array edges where edges[i] = [a_i, b_i] indicates that there is an edge between nodes a_i and b_i in the tree.\n\nReturn an array answer of length n where answer[i] is the sum of the distances between the i^th node in the tree and all other nodes.\n\nExample 1:\n\nInput: n = 6, edges = [[0,1],[0,2],[2,3],[2,4],[2,5]]\nOutput: [8,12,6,10,10,10]\nExplanation: The tree is shown above.\nWe can see that dist(0,1) + dist(0,2) + dist(0,3) + dist(0,4) + dist(0,5)\nequals 1 + 1 + 2 + 2 + 2 = 8.\nHence, answer[0] = 8, and so on.\n\nExample 2:\n\nInput: n = 1, edges = []\nOutput: [0]\n\nExample 3:\n\nInput: n = 2, edges = [[1,0]]\nOutput: [1,1]\n\nConstraints:\n\n- 1 <= n <= 3 * 10^4\n- edges.length == n - 1\n- edges[i].length == 2\n- 0 <= a_i, b_i < n\n- a_i != b_i\n- The given input represents a valid tree.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]]) == [15, 19, 19, 19, 27, 27, 27, 27, 27, 27]\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == [10, 11, 11, 16, 16, 16, 16]\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [1, 3]]) == [5, 3, 5, 5]\n assert candidate(n = 4,edges = [[0, 1], [0, 2], [1, 3]]) == [4, 4, 6, 6]\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]]) == [17, 11, 13, 13, 19, 19, 19, 19]\n assert candidate(n = 2,edges = [[1, 0]]) == [1, 1]\n assert candidate(n = 3,edges = [[0, 1], [0, 2]]) == [2, 3, 3]\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [2, 3], [2, 4], [2, 5]]) == [8, 12, 6, 10, 10, 10]\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [2, 3], [2, 4]]) == [6, 9, 5, 8, 8]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == [19, 17, 23, 21, 23, 31, 31, 29, 29, 31]\n assert candidate(n = 1,edges = []) == [0]\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [1, 4]]) == [6, 5, 9, 8, 8]\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [2, 3], [2, 4], [2, 5], [4, 6]]) == [11, 16, 8, 13, 11, 13, 16]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11]]) == [11, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]]) == [50, 46, 56, 56, 60, 60, 70, 70, 70, 74, 78, 78, 78, 78, 88, 88, 88, 88, 88, 88]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11]]) == [23, 21, 27, 27, 29, 31, 37, 37, 37, 37, 37, 39]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [4, 12], [5, 13], [5, 14]]) == [28, 31, 35, 35, 42, 40, 48, 48, 48, 48, 48, 48, 55, 53, 53]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [1, 7], [2, 8], [2, 9], [2, 10], [3, 11], [3, 12], [3, 13], [4, 14], [4, 15], [4, 16], [5, 17], [5, 18], [6, 19], [6, 20], [7, 21], [7, 22], [8, 23], [8, 24], [9, 25], [9, 26], [10, 27], [10, 28], [11, 29]]) == [67, 77, 77, 87, 89, 101, 101, 101, 101, 101, 101, 113, 115, 115, 117, 117, 117, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 141]\n assert candidate(n = 50,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [4, 15], [5, 16], [5, 17], [5, 18], [6, 19], [6, 20], [6, 21], [7, 22], [7, 23], [7, 24], [8, 25], [8, 26], [8, 27], [9, 28], [9, 29], [9, 30], [10, 31], [10, 32], [10, 33], [11, 34], [11, 35], [11, 36], [12, 37], [12, 38], [12, 39], [13, 40], [13, 41], [13, 42], [14, 43], [14, 44], [14, 45], [15, 46], [15, 47], [15, 48], [16, 49]]) == [142, 146, 166, 166, 170, 186, 188, 208, 208, 208, 208, 208, 208, 212, 212, 212, 232, 234, 234, 236, 236, 236, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 260, 260, 260, 260, 260, 260, 260, 260, 260, 280]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [4, 12], [4, 13], [4, 14], [5, 15], [5, 16], [5, 17], [6, 18], [6, 19], [6, 20], [7, 21], [7, 22], [7, 23], [8, 24], [8, 25], [8, 26], [9, 27], [9, 28], [9, 29]]) == [80, 78, 84, 94, 100, 100, 106, 106, 106, 116, 122, 122, 128, 128, 128, 128, 128, 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, 144, 144, 144]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19]]) == [41, 47, 49, 55, 55, 61, 61, 63, 65, 73, 73, 73, 73, 79, 79, 79, 79, 81, 81, 83]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14]]) == [30, 31, 37, 39, 40, 40, 48, 50, 52, 52, 53, 53, 53, 53, 61]\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20], [9, 21], [9, 22], [10, 23], [10, 24]]) == [69, 62, 78, 73, 77, 81, 95, 97, 92, 92, 96, 100, 104, 104, 118, 118, 118, 120, 120, 115, 115, 115, 115, 119, 119]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 8], [2, 9], [2, 10], [2, 11], [3, 12], [3, 13], [3, 14], [3, 15], [4, 16], [4, 17], [5, 18], [5, 19], [6, 20], [6, 21], [7, 22], [7, 23], [8, 24], [8, 25], [9, 26], [9, 27], [10, 28], [10, 29]]) == [69, 73, 77, 89, 97, 97, 97, 97, 101, 101, 101, 105, 117, 117, 117, 117, 125, 125, 125, 125, 125, 125, 125, 125, 129, 129, 129, 129, 129, 129]\n assert candidate(n = 22,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [9, 17], [10, 18], [11, 19], [12, 20], [13, 21]]) == [62, 62, 64, 74, 74, 76, 78, 92, 92, 92, 92, 94, 94, 96, 98, 112, 112, 112, 112, 114, 114, 116]\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [7, 20], [8, 21], [8, 22], [9, 23], [9, 24]]) == [57, 62, 62, 74, 81, 81, 81, 81, 81, 81, 97, 97, 97, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104]\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [105, 92, 81, 72, 65, 60, 57, 56, 57, 60, 65, 72, 81, 92, 105]\n assert candidate(n = 18,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [9, 17]]) == [46, 44, 50, 52, 54, 62, 62, 66, 66, 68, 70, 78, 78, 78, 78, 82, 82, 84]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == [34, 35, 35, 44, 44, 44, 44, 57, 57, 57, 57, 57, 57, 57, 57]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]]) == [26, 26, 28, 32, 34, 36, 36, 40, 44, 46, 46, 50]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25], [12, 26], [12, 27], [13, 28], [13, 29]]) == [83, 83, 99, 99, 99, 99, 123, 123, 123, 123, 123, 123, 123, 123, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151]\n assert candidate(n = 35,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [4, 15], [5, 16], [5, 17], [5, 18], [6, 19], [6, 20], [6, 21], [7, 22], [7, 23], [7, 24], [8, 25], [8, 26], [8, 27], [9, 28], [9, 29], [9, 30], [10, 31], [10, 32], [10, 33], [11, 34]]) == [87, 96, 96, 106, 123, 123, 123, 123, 123, 123, 133, 137, 139, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 166, 166, 166, 170]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [4, 9]]) == [19, 17, 23, 23, 21, 31, 31, 31, 29, 29]\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24]]) == [74, 69, 81, 80, 80, 96, 100, 99, 99, 99, 99, 115, 119, 123, 123, 122, 122, 122, 122, 122, 122, 122, 122, 138, 138]\n assert candidate(n = 12,edges = [[0, 1], [0, 5], [1, 2], [1, 3], [1, 4], [5, 6], [5, 7], [5, 8], [8, 9], [8, 10], [8, 11]]) == [23, 27, 37, 37, 37, 21, 31, 31, 25, 35, 35, 35]\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [5, 17], [6, 18], [6, 19], [6, 20], [7, 21], [7, 22], [8, 23], [8, 24]]) == [57, 58, 66, 74, 77, 75, 75, 85, 85, 89, 97, 97, 97, 100, 100, 98, 98, 98, 98, 98, 98, 108, 108, 108, 108]\n assert candidate(n = 27,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 20], [10, 21], [11, 22], [12, 23], [12, 24], [13, 25], [14, 26]]) == [82, 81, 85, 94, 96, 100, 102, 115, 115, 119, 117, 123, 121, 125, 125, 140, 140, 140, 140, 144, 142, 142, 148, 146, 146, 150, 150]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [7, 18], [7, 19]]) == [43, 49, 47, 55, 63, 63, 61, 61, 65, 73, 73, 73, 81, 81, 81, 81, 79, 79, 79, 79]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == [54, 50, 60, 56, 62, 74, 74, 70, 70, 78, 80, 92, 92, 92, 92, 88, 88, 88, 88, 96]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29]]) == [94, 94, 96, 110, 110, 112, 114, 134, 134, 134, 134, 136, 136, 138, 140, 162, 162, 162, 162, 162, 162, 162, 162, 164, 164, 164, 164, 166, 166, 168]\n", "comparison": "exact"}, "public_tests": ["6\n[[0,1],[0,2],[2,3],[2,4],[2,5]]", "1\n[]", "2\n[[1,0]]"], "hints": [], "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().sumOfDistancesInTree", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:21+00:00", "tests_total": 40, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["dynamic-programming", "tree", "depth-first-search", "graph", "dp-on-trees"]}, "language": "java", "interface": {"raw_signature": "public int[] sumOfDistancesInTree(int n, int[][] edges) {", "container": "Solution", "callable": "sumOfDistancesInTree", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "int[][]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 835, "task_id": "image-overlap", "difficulty": "Medium", "problem_description": "You are given two images, img1 and img2, represented as binary, square matrices of size n x n. A binary matrix has only 0s and 1s as values.\n\nWe translate one image however we choose by sliding all the 1 bits left, right, up, and/or down any number of units. We then place it on top of the other image. We can then calculate the overlap by counting the number of positions that have a 1 in both images.\n\nNote also that a translation does not include any kind of rotation. Any 1 bits that are translated outside of the matrix borders are erased.\n\nReturn the largest possible overlap.\n\nExample 1:\n\nInput: img1 = [[1,1,0],[0,1,0],[0,1,0]], img2 = [[0,0,0],[0,1,1],[0,0,1]]\nOutput: 3\nExplanation: We translate img1 to right by 1 unit and down by 1 unit.\n\nThe number of positions that have a 1 in both images is 3 (shown in red).\n\nExample 2:\n\nInput: img1 = [[1]], img2 = [[1]]\nOutput: 1\n\nExample 3:\n\nInput: img1 = [[0]], img2 = [[0]]\nOutput: 0\n\nConstraints:\n\n- n == img1.length == img1[i].length\n- n == img2.length == img2[i].length\n- 1 <= n <= 30\n- img1[i][j] is either 0 or 1.\n- img2[i][j] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(img1 = [[1, 1, 0], [0, 1, 0], [0, 1, 0]],img2 = [[0, 0, 0], [0, 1, 1], [0, 0, 1]]) == 3\n assert candidate(img1 = [[1, 0], [0, 1]],img2 = [[1, 1], [1, 1]]) == 2\n assert candidate(img1 = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],img2 = [[0, 1, 0], [1, 1, 1], [0, 1, 0]]) == 5\n assert candidate(img1 = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],img2 = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(img1 = [[1]],img2 = [[1]]) == 1\n assert candidate(img1 = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],img2 = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 9\n assert candidate(img1 = [[1, 1], [1, 1]],img2 = [[0, 0], [0, 0]]) == 0\n assert candidate(img1 = [[0]],img2 = [[0]]) == 0\n assert candidate(img1 = [[1, 0, 1], [0, 1, 0], [1, 0, 1]],img2 = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 5\n assert candidate(img1 = [[1, 0], [0, 1]],img2 = [[1, 1], [1, 0]]) == 1\n assert candidate(img1 = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],img2 = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(img1 = [[1, 0], [0, 1]],img2 = [[1, 0], [0, 1]]) == 2\n assert candidate(img1 = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1]],img2 = [[0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0]]) == 6\n assert candidate(img1 = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],img2 = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 16\n assert candidate(img1 = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],img2 = [[0, 0, 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(img1 = [[0, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [1, 0, 0, 0, 0]],img2 = [[1, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 1]]) == 4\n assert candidate(img1 = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]],img2 = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 5\n assert candidate(img1 = [[1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [1, 1, 1, 0, 0]],img2 = [[1, 0, 0, 1, 1], [1, 1, 1, 0, 0], [1, 0, 0, 1, 1], [1, 1, 1, 0, 0], [1, 0, 0, 1, 1]]) == 10\n assert candidate(img1 = [[1, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0], [1, 0, 0, 1]],img2 = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(img1 = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],img2 = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 4\n assert candidate(img1 = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1]],img2 = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 2\n assert candidate(img1 = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]],img2 = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0]]) == 1\n assert candidate(img1 = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],img2 = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 12\n assert candidate(img1 = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]],img2 = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 13\n assert candidate(img1 = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]],img2 = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == 3\n assert candidate(img1 = [[1, 1, 1, 0], [1, 0, 0, 1], [0, 1, 0, 1], [1, 0, 1, 0]],img2 = [[0, 0, 1, 1], [0, 1, 1, 0], [1, 1, 0, 0], [1, 0, 0, 0]]) == 3\n assert candidate(img1 = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],img2 = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]]) == 8\n assert candidate(img1 = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]],img2 = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 12\n assert candidate(img1 = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],img2 = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 4\n assert candidate(img1 = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]],img2 = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 9\n assert candidate(img1 = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]],img2 = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(img1 = [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [1, 0, 0, 1]],img2 = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 4\n assert candidate(img1 = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]],img2 = [[0, 0, 0, 0], [0, 0, 0, 0], [1, 1, 0, 0], [1, 1, 0, 0]]) == 4\n assert candidate(img1 = [[1, 1, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1]],img2 = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == 1\n assert candidate(img1 = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]],img2 = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]) == 9\n assert candidate(img1 = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],img2 = [[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]]) == 1\n assert candidate(img1 = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],img2 = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 10\n assert candidate(img1 = [[0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [1, 0, 0, 0, 0]],img2 = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 4\n assert candidate(img1 = [[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]],img2 = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 4\n assert candidate(img1 = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],img2 = [[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 2\n assert candidate(img1 = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],img2 = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 1\n assert candidate(img1 = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]],img2 = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 10\n assert candidate(img1 = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],img2 = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]) == 4\n assert candidate(img1 = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]],img2 = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 4\n assert candidate(img1 = [[0, 1, 1, 0], [1, 1, 1, 1], [1, 1, 1, 1], [0, 1, 1, 0]],img2 = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 4\n assert candidate(img1 = [[1, 0, 0, 1], [0, 1, 1, 0], [1, 1, 0, 0], [0, 0, 1, 1]],img2 = [[0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0]]) == 5\n assert candidate(img1 = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],img2 = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == 6\n assert candidate(img1 = [[1, 1, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 1, 1]],img2 = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 4\n assert candidate(img1 = [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [1, 0, 0, 1]],img2 = [[0, 0, 1, 0], [0, 1, 1, 0], [1, 1, 0, 0], [0, 0, 0, 1]]) == 3\n assert candidate(img1 = [[1, 1, 0, 1], [0, 1, 1, 0], [1, 0, 0, 1], [0, 1, 0, 1]],img2 = [[1, 0, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [0, 1, 0, 0]]) == 5\n assert candidate(img1 = [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [1, 0, 0, 1]],img2 = [[0, 0, 1, 1], [1, 0, 0, 1], [0, 1, 1, 0], [1, 1, 0, 0]]) == 4\n assert candidate(img1 = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]],img2 = [[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]]) == 6\n assert candidate(img1 = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],img2 = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]]) == 1\n assert candidate(img1 = [[1, 1, 1, 0], [0, 1, 1, 0], [0, 0, 1, 1], [0, 0, 0, 1]],img2 = [[1, 0, 0, 1], [1, 1, 0, 0], [0, 1, 1, 0], [0, 1, 0, 1]]) == 5\n assert candidate(img1 = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]],img2 = [[0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0]]) == 5\n assert candidate(img1 = [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [0, 0, 0, 1]],img2 = [[0, 0, 1, 1], [0, 1, 1, 0], [1, 1, 0, 0], [0, 0, 0, 1]]) == 3\n assert candidate(img1 = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [0, 0, 0, 0, 1]],img2 = [[0, 0, 0, 0, 1], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [1, 1, 0, 0, 0], [1, 1, 0, 0, 0]]) == 4\n assert candidate(img1 = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]],img2 = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == 4\n assert candidate(img1 = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]],img2 = [[0, 0, 1, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 1, 0, 0]]) == 6\n assert candidate(img1 = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]],img2 = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == 1\n assert candidate(img1 = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],img2 = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 2\n assert candidate(img1 = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],img2 = [[1, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) == 2\n assert candidate(img1 = [[1, 0, 0, 1], [0, 1, 1, 0], [1, 1, 0, 1], [0, 0, 1, 0]],img2 = [[0, 0, 1, 0], [1, 1, 0, 1], [0, 1, 1, 0], [1, 0, 0, 1]]) == 6\n assert candidate(img1 = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]],img2 = [[0, 0, 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(img1 = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]],img2 = [[1, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0], [1, 0, 0, 1]]) == 4\n assert candidate(img1 = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],img2 = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == 5\n assert candidate(img1 = [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [0, 0, 0, 1]],img2 = [[0, 0, 1, 1], [0, 1, 1, 0], [1, 1, 0, 0], [1, 0, 0, 0]]) == 2\n assert candidate(img1 = [[1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1], [1, 1, 1, 0, 0]],img2 = [[0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [1, 1, 0, 0, 1], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0]]) == 8\n assert candidate(img1 = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]],img2 = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == 8\n assert candidate(img1 = [[0, 1, 1, 1], [1, 1, 1, 0], [1, 1, 1, 0], [0, 1, 1, 1]],img2 = [[1, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 1]]) == 6\n assert candidate(img1 = [[1, 1, 0, 0, 0], [0, 1, 1, 0, 0], [0, 0, 1, 1, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]],img2 = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 1], [0, 0, 1, 1, 0], [0, 1, 1, 0, 0], [1, 1, 0, 0, 0]]) == 2\n assert candidate(img1 = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]],img2 = [[0, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0], [1, 0, 0, 0]]) == 1\n assert candidate(img1 = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],img2 = [[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 5\n assert candidate(img1 = [[1, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]],img2 = [[0, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0]]) == 1\n assert candidate(img1 = [[1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1]],img2 = [[0, 0, 0, 1, 1], [0, 0, 0, 1, 1], [1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 0, 0]]) == 9\n", "comparison": "exact"}, "public_tests": ["[[1,1,0],[0,1,0],[0,1,0]]\n[[0,0,0],[0,1,1],[0,0,1]]", "[[1]]\n[[1]]", "[[0]]\n[[0]]"], "hints": [], "metadata": {"canonical_parameter_names": ["img1", "img2"], "leetcode_dataset_entry_point": "Solution().largestOverlap", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:23+00:00", "tests_total": 75, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "matrix"]}, "language": "java", "interface": {"raw_signature": "public int largestOverlap(int[][] img1, int[][] img2) {", "container": "Solution", "callable": "largestOverlap", "parameters": [{"name": "img1", "type": "int[][]"}, {"name": "img2", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 836, "task_id": "rectangle-overlap", "difficulty": "Easy", "problem_description": "An axis-aligned rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) is the coordinate of its bottom-left corner, and (x2, y2) is the coordinate of its top-right corner. Its top and bottom edges are parallel to the X-axis, and its left and right edges are parallel to the Y-axis.\n\nTwo rectangles overlap if the area of their intersection is positive. To be clear, two rectangles that only touch at the corner or edges do not overlap.\n\nGiven two axis-aligned rectangles rec1 and rec2, return true if they overlap, otherwise return false.\n\nExample 1:\n\nInput: rec1 = [0,0,2,2], rec2 = [1,1,3,3]\nOutput: true\n\nExample 2:\n\nInput: rec1 = [0,0,1,1], rec2 = [1,0,2,1]\nOutput: false\n\nExample 3:\n\nInput: rec1 = [0,0,1,1], rec2 = [2,2,3,3]\nOutput: false\n\nConstraints:\n\n- rec1.length == 4\n- rec2.length == 4\n- -10^9 <= rec1[i], rec2[i] <= 10^9\n- rec1 and rec2 represent a valid rectangle with a non-zero area.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rec1 = [-5, -5, -3, -3],rec2 = [-4, -4, -2, -2]) == True\n assert candidate(rec1 = [1, 1, 5, 5],rec2 = [4, 4, 8, 8]) == True\n assert candidate(rec1 = [-5, -5, -2, -2],rec2 = [-4, -4, -1, -1]) == True\n assert candidate(rec1 = [-2, -2, 0, 0],rec2 = [-1, -1, 1, 1]) == True\n assert candidate(rec1 = [1, 1, 4, 4],rec2 = [0, 0, 3, 3]) == True\n assert candidate(rec1 = [5, 5, 10, 10],rec2 = [1, 1, 6, 6]) == True\n assert candidate(rec1 = [5, 5, 10, 10],rec2 = [8, 8, 15, 15]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [5, 5, 10, 10]) == False\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [2, 2, 3, 3]) == False\n assert candidate(rec1 = [1, 1, 3, 3],rec2 = [2, 2, 4, 4]) == True\n assert candidate(rec1 = [1, 1, 2, 2],rec2 = [2, 2, 3, 3]) == False\n assert candidate(rec1 = [1, 1, 3, 3],rec2 = [0, 0, 1, 1]) == False\n assert candidate(rec1 = [5, 5, 10, 10],rec2 = [10, 10, 15, 15]) == False\n assert candidate(rec1 = [5, 5, 10, 10],rec2 = [11, 11, 16, 16]) == False\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [1, 0, 2, 1]) == False\n assert candidate(rec1 = [-5, -5, -2, -2],rec2 = [-3, -3, -1, -1]) == True\n assert candidate(rec1 = [0, 0, 2, 2],rec2 = [1, 1, 3, 3]) == True\n assert candidate(rec1 = [1, 1, 3, 3],rec2 = [0, 0, 2, 2]) == True\n assert candidate(rec1 = [5, 5, 10, 10],rec2 = [6, 6, 11, 11]) == True\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [0, 0, 2, 2]) == True\n assert candidate(rec1 = [-200000000, -200000000, -100000000, -100000000],rec2 = [-150000000, -150000000, -50000000, -50000000]) == True\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [10, 10, 20, 20]) == False\n assert candidate(rec1 = [0, 0, 2, 2],rec2 = [1, -1, 3, 1]) == True\n assert candidate(rec1 = [1, 2, 3, 4],rec2 = [2, 3, 5, 6]) == True\n assert candidate(rec1 = [1, 2, 3, 4],rec2 = [2, 3, 4, 5]) == True\n assert candidate(rec1 = [0, 0, 1000, 1000],rec2 = [500, 500, 1500, 1500]) == True\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [-2, -2, 0, 0]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [5, 5, 10, 10]) == False\n assert candidate(rec1 = [10, 20, 30, 40],rec2 = [25, 35, 45, 55]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [6, 6, 10, 10]) == False\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [-5, -5, 5, 5]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [5, 0, 10, 5]) == False\n assert candidate(rec1 = [-5, 0, 5, 10],rec2 = [0, -10, 10, 0]) == False\n assert candidate(rec1 = [100, 200, 300, 400],rec2 = [250, 250, 350, 350]) == True\n assert candidate(rec1 = [1000, 1000, 2000, 2000],rec2 = [500, 500, 1500, 1500]) == True\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [5, -5, 15, 5]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [0.9, 0.9, 2, 2]) == True\n assert candidate(rec1 = [-1000000000, -1000000000, 1000000000, 1000000000],rec2 = [0, 0, 1, 1]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [-1, -1, 0, 0]) == False\n assert candidate(rec1 = [-10, -10, 0, 0],rec2 = [0, 0, 10, 10]) == False\n assert candidate(rec1 = [0, 0, 100, 100],rec2 = [50, 50, 150, 150]) == True\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [5, 5, 15, 15]) == True\n assert candidate(rec1 = [-5, -5, 5, 5],rec2 = [-10, -10, -5, -5]) == False\n assert candidate(rec1 = [10, 20, 30, 40],rec2 = [25, 35, 35, 45]) == True\n assert candidate(rec1 = [0, 0, 100, 100],rec2 = [99, 99, 200, 200]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [0.5, 0.5, 1.5, 1.5]) == True\n assert candidate(rec1 = [10, 10, 15, 15],rec2 = [12, 12, 18, 18]) == True\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [5, 5, 15, 15]) == True\n assert candidate(rec1 = [-100, 100, -50, 150],rec2 = [-75, 125, -25, 175]) == True\n assert candidate(rec1 = [1, 1, 4, 4],rec2 = [2, 2, 3, 3]) == True\n assert candidate(rec1 = [-100, -200, -50, -150],rec2 = [-75, -175, -25, -125]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [0, 5, 5, 10]) == False\n assert candidate(rec1 = [-10, -10, 0, 0],rec2 = [-5, -5, 5, 5]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [0, 1, 1, 2]) == False\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [15, 15, 25, 25]) == True\n assert candidate(rec1 = [-10, 20, -5, 25],rec2 = [-7, 15, -2, 22]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [0, -1, 1, 0]) == False\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [5, -5, 15, 5]) == True\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [10, 10, 20, 20]) == True\n assert candidate(rec1 = [100, 100, 200, 200],rec2 = [200, 200, 300, 300]) == False\n assert candidate(rec1 = [1, 1, 5, 5],rec2 = [5, 5, 9, 9]) == False\n assert candidate(rec1 = [-1, 0, 0, 1],rec2 = [0, -1, 1, 0]) == False\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [1, 1, 2, 2]) == False\n assert candidate(rec1 = [-10, -20, -5, -15],rec2 = [-7, -18, -3, -12]) == True\n assert candidate(rec1 = [-10, -10, 10, 10],rec2 = [-5, -5, 5, 5]) == True\n assert candidate(rec1 = [1, 1, 5, 5],rec2 = [1, 6, 5, 10]) == False\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [10, 0, 20, 10]) == False\n assert candidate(rec1 = [1, 2, 3, 4],rec2 = [4, 3, 5, 2]) == False\n assert candidate(rec1 = [-1000000000, -1000000000, 1000000000, 1000000000],rec2 = [0, 0, 1, 1]) == True\n assert candidate(rec1 = [1, 1, 5, 5],rec2 = [1, 1, 6, 6]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [1, 0, 2, 1]) == False\n assert candidate(rec1 = [100000000, 100000000, 200000000, 200000000],rec2 = [150000000, 150000000, 250000000, 250000000]) == True\n assert candidate(rec1 = [1, 1, 5, 5],rec2 = [6, 1, 10, 5]) == False\n assert candidate(rec1 = [10, 20, 30, 40],rec2 = [25, 35, 45, 55]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [1, 1, 2, 2]) == False\n assert candidate(rec1 = [1, 2, 3, 4],rec2 = [3, 4, 5, 6]) == False\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [9, 9, 11, 11]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [1.5, 1.5, 2.5, 2.5]) == False\n assert candidate(rec1 = [1000, 1000, 2000, 2000],rec2 = [1500, 1500, 2500, 2500]) == True\n assert candidate(rec1 = [-10, -10, 10, 10],rec2 = [9, 9, 20, 20]) == True\n assert candidate(rec1 = [-500000000, -500000000, 500000000, 500000000],rec2 = [0, 0, 1, 1]) == True\n assert candidate(rec1 = [0, 0, 100, 100],rec2 = [90, 90, 200, 200]) == True\n assert candidate(rec1 = [1, 1, 4, 4],rec2 = [4, 4, 7, 7]) == False\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [21, 21, 30, 30]) == False\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [-5, -5, 0, 0]) == False\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [20, 20, 30, 30]) == False\n assert candidate(rec1 = [2, 2, 5, 5],rec2 = [5, 5, 8, 8]) == False\n assert candidate(rec1 = [1, 2, 4, 5],rec2 = [3, 3, 6, 6]) == True\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [-10, -10, 0, 0]) == False\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [0, 0, 2, 2]) == True\n assert candidate(rec1 = [-100, -100, 0, 0],rec2 = [-50, -50, 50, 50]) == True\n assert candidate(rec1 = [-1000000, -1000000, -900000, -900000],rec2 = [-950000, -950000, -850000, -850000]) == True\n assert candidate(rec1 = [-100, -100, 0, 0],rec2 = [0, 0, 100, 100]) == False\n assert candidate(rec1 = [10, 20, 30, 40],rec2 = [25, 30, 35, 45]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [0.5, 0.5, 1.5, 1.5]) == True\n assert candidate(rec1 = [-20, -20, -10, -10],rec2 = [-15, -15, -5, -5]) == True\n assert candidate(rec1 = [15, 25, 30, 45],rec2 = [20, 30, 40, 50]) == True\n assert candidate(rec1 = [1, 1, 2, 2],rec2 = [1.5, 1.5, 2.5, 2.5]) == True\n assert candidate(rec1 = [1, 1, 10, 10],rec2 = [5, 5, 5, 10]) == True\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [-2, -2, 0, 0]) == True\n assert candidate(rec1 = [100, 100, 200, 200],rec2 = [150, 150, 250, 250]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [1, 1, 2, 2]) == False\n assert candidate(rec1 = [1, 2, 3, 4],rec2 = [2, 1, 4, 3]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [-5, -5, 0, 0]) == False\n assert candidate(rec1 = [-2, -2, 2, 2],rec2 = [2, 2, 4, 4]) == False\n assert candidate(rec1 = [0, 0, 100, 100],rec2 = [50, 50, 150, 150]) == True\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [-2, -2, 2, 2]) == True\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [15, 15, 25, 25]) == True\n assert candidate(rec1 = [-1000000000, -1000000000, 0, 0],rec2 = [-500000000, -500000000, 500000000, 500000000]) == True\n assert candidate(rec1 = [-10, -10, 0, 0],rec2 = [-5, -5, 5, 5]) == True\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [20, 20, 30, 30]) == False\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [2, 2, 8, 8]) == True\n assert candidate(rec1 = [-10, -10, -5, -5],rec2 = [-8, -8, -3, -3]) == True\n assert candidate(rec1 = [-1000, -1000, 1000, 1000],rec2 = [-2000, -2000, 0, 0]) == True\n assert candidate(rec1 = [5, 5, 15, 15],rec2 = [5, 15, 15, 25]) == False\n assert candidate(rec1 = [100, 100, 200, 200],rec2 = [150, 150, 250, 250]) == True\n assert candidate(rec1 = [1, 1, 2, 2],rec2 = [0, 0, 100, 100]) == True\n assert candidate(rec1 = [-1, -2, 1, 2],rec2 = [-2, -3, 2, 3]) == True\n assert candidate(rec1 = [-1000000000, -1000000000, 0, 0],rec2 = [-500000000, -500000000, 500000000, 500000000]) == True\n", "comparison": "exact"}, "public_tests": ["[0,0,2,2]\n[1,1,3,3]", "[0,0,1,1]\n[1,0,2,1]", "[0,0,1,1]\n[2,2,3,3]"], "hints": [], "metadata": {"canonical_parameter_names": ["rec1", "rec2"], "leetcode_dataset_entry_point": "Solution().isRectangleOverlap", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:26+00:00", "tests_total": 122, "tests_dropped": 3, "flags": [], "topic_tags": ["math", "geometry"]}, "language": "java", "interface": {"raw_signature": "public boolean isRectangleOverlap(int[] rec1, int[] rec2) {", "container": "Solution", "callable": "isRectangleOverlap", "parameters": [{"name": "rec1", "type": "int[]"}, {"name": "rec2", "type": "int[]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 836, "task_id": "rectangle-overlap", "difficulty": "Easy", "problem_description": "An axis-aligned rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) is the coordinate of its bottom-left corner, and (x2, y2) is the coordinate of its top-right corner. Its top and bottom edges are parallel to the X-axis, and its left and right edges are parallel to the Y-axis.\n\nTwo rectangles overlap if the area of their intersection is positive. To be clear, two rectangles that only touch at the corner or edges do not overlap.\n\nGiven two axis-aligned rectangles rec1 and rec2, return true if they overlap, otherwise return false.\n\nExample 1:\n\nInput: rec1 = [0,0,2,2], rec2 = [1,1,3,3]\nOutput: true\n\nExample 2:\n\nInput: rec1 = [0,0,1,1], rec2 = [1,0,2,1]\nOutput: false\n\nExample 3:\n\nInput: rec1 = [0,0,1,1], rec2 = [2,2,3,3]\nOutput: false\n\nConstraints:\n\n- rec1.length == 4\n- rec2.length == 4\n- -10^9 <= rec1[i], rec2[i] <= 10^9\n- rec1 and rec2 represent a valid rectangle with a non-zero area.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rec1 = [-5, -5, -3, -3],rec2 = [-4, -4, -2, -2]) == True\n assert candidate(rec1 = [1, 1, 5, 5],rec2 = [4, 4, 8, 8]) == True\n assert candidate(rec1 = [-5, -5, -2, -2],rec2 = [-4, -4, -1, -1]) == True\n assert candidate(rec1 = [-2, -2, 0, 0],rec2 = [-1, -1, 1, 1]) == True\n assert candidate(rec1 = [1, 1, 4, 4],rec2 = [0, 0, 3, 3]) == True\n assert candidate(rec1 = [5, 5, 10, 10],rec2 = [1, 1, 6, 6]) == True\n assert candidate(rec1 = [5, 5, 10, 10],rec2 = [8, 8, 15, 15]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [5, 5, 10, 10]) == False\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [2, 2, 3, 3]) == False\n assert candidate(rec1 = [1, 1, 3, 3],rec2 = [2, 2, 4, 4]) == True\n assert candidate(rec1 = [1, 1, 2, 2],rec2 = [2, 2, 3, 3]) == False\n assert candidate(rec1 = [1, 1, 3, 3],rec2 = [0, 0, 1, 1]) == False\n assert candidate(rec1 = [5, 5, 10, 10],rec2 = [10, 10, 15, 15]) == False\n assert candidate(rec1 = [5, 5, 10, 10],rec2 = [11, 11, 16, 16]) == False\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [1, 0, 2, 1]) == False\n assert candidate(rec1 = [-5, -5, -2, -2],rec2 = [-3, -3, -1, -1]) == True\n assert candidate(rec1 = [0, 0, 2, 2],rec2 = [1, 1, 3, 3]) == True\n assert candidate(rec1 = [1, 1, 3, 3],rec2 = [0, 0, 2, 2]) == True\n assert candidate(rec1 = [5, 5, 10, 10],rec2 = [6, 6, 11, 11]) == True\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [0, 0, 2, 2]) == True\n assert candidate(rec1 = [-200000000, -200000000, -100000000, -100000000],rec2 = [-150000000, -150000000, -50000000, -50000000]) == True\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [10, 10, 20, 20]) == False\n assert candidate(rec1 = [0, 0, 2, 2],rec2 = [1, -1, 3, 1]) == True\n assert candidate(rec1 = [1, 2, 3, 4],rec2 = [2, 3, 5, 6]) == True\n assert candidate(rec1 = [1, 2, 3, 4],rec2 = [2, 3, 4, 5]) == True\n assert candidate(rec1 = [0, 0, 1000, 1000],rec2 = [500, 500, 1500, 1500]) == True\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [-2, -2, 0, 0]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [5, 5, 10, 10]) == False\n assert candidate(rec1 = [10, 20, 30, 40],rec2 = [25, 35, 45, 55]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [6, 6, 10, 10]) == False\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [-5, -5, 5, 5]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [5, 0, 10, 5]) == False\n assert candidate(rec1 = [-5, 0, 5, 10],rec2 = [0, -10, 10, 0]) == False\n assert candidate(rec1 = [100, 200, 300, 400],rec2 = [250, 250, 350, 350]) == True\n assert candidate(rec1 = [1000, 1000, 2000, 2000],rec2 = [500, 500, 1500, 1500]) == True\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [5, -5, 15, 5]) == True\n assert candidate(rec1 = [-1000000000, -1000000000, 1000000000, 1000000000],rec2 = [0, 0, 1, 1]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [-1, -1, 0, 0]) == False\n assert candidate(rec1 = [-10, -10, 0, 0],rec2 = [0, 0, 10, 10]) == False\n assert candidate(rec1 = [0, 0, 100, 100],rec2 = [50, 50, 150, 150]) == True\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [5, 5, 15, 15]) == True\n assert candidate(rec1 = [-5, -5, 5, 5],rec2 = [-10, -10, -5, -5]) == False\n assert candidate(rec1 = [10, 20, 30, 40],rec2 = [25, 35, 35, 45]) == True\n assert candidate(rec1 = [0, 0, 100, 100],rec2 = [99, 99, 200, 200]) == True\n assert candidate(rec1 = [10, 10, 15, 15],rec2 = [12, 12, 18, 18]) == True\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [5, 5, 15, 15]) == True\n assert candidate(rec1 = [-100, 100, -50, 150],rec2 = [-75, 125, -25, 175]) == True\n assert candidate(rec1 = [1, 1, 4, 4],rec2 = [2, 2, 3, 3]) == True\n assert candidate(rec1 = [-100, -200, -50, -150],rec2 = [-75, -175, -25, -125]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [0, 5, 5, 10]) == False\n assert candidate(rec1 = [-10, -10, 0, 0],rec2 = [-5, -5, 5, 5]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [0, 1, 1, 2]) == False\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [15, 15, 25, 25]) == True\n assert candidate(rec1 = [-10, 20, -5, 25],rec2 = [-7, 15, -2, 22]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [0, -1, 1, 0]) == False\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [5, -5, 15, 5]) == True\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [10, 10, 20, 20]) == True\n assert candidate(rec1 = [100, 100, 200, 200],rec2 = [200, 200, 300, 300]) == False\n assert candidate(rec1 = [1, 1, 5, 5],rec2 = [5, 5, 9, 9]) == False\n assert candidate(rec1 = [-1, 0, 0, 1],rec2 = [0, -1, 1, 0]) == False\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [1, 1, 2, 2]) == False\n assert candidate(rec1 = [-10, -20, -5, -15],rec2 = [-7, -18, -3, -12]) == True\n assert candidate(rec1 = [-10, -10, 10, 10],rec2 = [-5, -5, 5, 5]) == True\n assert candidate(rec1 = [1, 1, 5, 5],rec2 = [1, 6, 5, 10]) == False\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [10, 0, 20, 10]) == False\n assert candidate(rec1 = [1, 2, 3, 4],rec2 = [4, 3, 5, 2]) == False\n assert candidate(rec1 = [-1000000000, -1000000000, 1000000000, 1000000000],rec2 = [0, 0, 1, 1]) == True\n assert candidate(rec1 = [1, 1, 5, 5],rec2 = [1, 1, 6, 6]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [1, 0, 2, 1]) == False\n assert candidate(rec1 = [100000000, 100000000, 200000000, 200000000],rec2 = [150000000, 150000000, 250000000, 250000000]) == True\n assert candidate(rec1 = [1, 1, 5, 5],rec2 = [6, 1, 10, 5]) == False\n assert candidate(rec1 = [10, 20, 30, 40],rec2 = [25, 35, 45, 55]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [1, 1, 2, 2]) == False\n assert candidate(rec1 = [1, 2, 3, 4],rec2 = [3, 4, 5, 6]) == False\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [9, 9, 11, 11]) == True\n assert candidate(rec1 = [1000, 1000, 2000, 2000],rec2 = [1500, 1500, 2500, 2500]) == True\n assert candidate(rec1 = [-10, -10, 10, 10],rec2 = [9, 9, 20, 20]) == True\n assert candidate(rec1 = [-500000000, -500000000, 500000000, 500000000],rec2 = [0, 0, 1, 1]) == True\n assert candidate(rec1 = [0, 0, 100, 100],rec2 = [90, 90, 200, 200]) == True\n assert candidate(rec1 = [1, 1, 4, 4],rec2 = [4, 4, 7, 7]) == False\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [21, 21, 30, 30]) == False\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [-5, -5, 0, 0]) == False\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [20, 20, 30, 30]) == False\n assert candidate(rec1 = [2, 2, 5, 5],rec2 = [5, 5, 8, 8]) == False\n assert candidate(rec1 = [1, 2, 4, 5],rec2 = [3, 3, 6, 6]) == True\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [-10, -10, 0, 0]) == False\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [0, 0, 2, 2]) == True\n assert candidate(rec1 = [-100, -100, 0, 0],rec2 = [-50, -50, 50, 50]) == True\n assert candidate(rec1 = [-1000000, -1000000, -900000, -900000],rec2 = [-950000, -950000, -850000, -850000]) == True\n assert candidate(rec1 = [-100, -100, 0, 0],rec2 = [0, 0, 100, 100]) == False\n assert candidate(rec1 = [10, 20, 30, 40],rec2 = [25, 30, 35, 45]) == True\n assert candidate(rec1 = [-20, -20, -10, -10],rec2 = [-15, -15, -5, -5]) == True\n assert candidate(rec1 = [15, 25, 30, 45],rec2 = [20, 30, 40, 50]) == True\n assert candidate(rec1 = [1, 1, 10, 10],rec2 = [5, 5, 5, 10]) == True\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [-2, -2, 0, 0]) == True\n assert candidate(rec1 = [100, 100, 200, 200],rec2 = [150, 150, 250, 250]) == True\n assert candidate(rec1 = [0, 0, 1, 1],rec2 = [1, 1, 2, 2]) == False\n assert candidate(rec1 = [1, 2, 3, 4],rec2 = [2, 1, 4, 3]) == True\n assert candidate(rec1 = [0, 0, 5, 5],rec2 = [-5, -5, 0, 0]) == False\n assert candidate(rec1 = [-2, -2, 2, 2],rec2 = [2, 2, 4, 4]) == False\n assert candidate(rec1 = [0, 0, 100, 100],rec2 = [50, 50, 150, 150]) == True\n assert candidate(rec1 = [-1, -1, 1, 1],rec2 = [-2, -2, 2, 2]) == True\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [15, 15, 25, 25]) == True\n assert candidate(rec1 = [-1000000000, -1000000000, 0, 0],rec2 = [-500000000, -500000000, 500000000, 500000000]) == True\n assert candidate(rec1 = [-10, -10, 0, 0],rec2 = [-5, -5, 5, 5]) == True\n assert candidate(rec1 = [10, 10, 20, 20],rec2 = [20, 20, 30, 30]) == False\n assert candidate(rec1 = [0, 0, 10, 10],rec2 = [2, 2, 8, 8]) == True\n assert candidate(rec1 = [-10, -10, -5, -5],rec2 = [-8, -8, -3, -3]) == True\n assert candidate(rec1 = [-1000, -1000, 1000, 1000],rec2 = [-2000, -2000, 0, 0]) == True\n assert candidate(rec1 = [5, 5, 15, 15],rec2 = [5, 15, 15, 25]) == False\n assert candidate(rec1 = [100, 100, 200, 200],rec2 = [150, 150, 250, 250]) == True\n assert candidate(rec1 = [1, 1, 2, 2],rec2 = [0, 0, 100, 100]) == True\n assert candidate(rec1 = [-1, -2, 1, 2],rec2 = [-2, -3, 2, 3]) == True\n assert candidate(rec1 = [-1000000000, -1000000000, 0, 0],rec2 = [-500000000, -500000000, 500000000, 500000000]) == True\n", "comparison": "exact"}, "public_tests": ["[0,0,2,2]\n[1,1,3,3]", "[0,0,1,1]\n[1,0,2,1]", "[0,0,1,1]\n[2,2,3,3]"], "hints": [], "metadata": {"canonical_parameter_names": ["rec1", "rec2"], "leetcode_dataset_entry_point": "Solution().isRectangleOverlap", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:26+00:00", "tests_total": 122, "tests_dropped": 8, "flags": [], "topic_tags": ["math", "geometry"]}, "language": "java", "interface": {"raw_signature": "public boolean isRectangleOverlap(int[] rec1, int[] rec2) {", "container": "Solution", "callable": "isRectangleOverlap", "parameters": [{"name": "rec1", "type": "int[]"}, {"name": "rec2", "type": "int[]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 837, "task_id": "new-21-game", "difficulty": "Medium", "problem_description": "Alice plays the following game, loosely based on the card game \"21\".\n\nAlice starts with 0 points and draws numbers while she has less than k points. During each draw, she gains an integer number of points randomly from the range [1, maxPts], where maxPts is an integer. Each draw is independent and the outcomes have equal probabilities.\n\nAlice stops drawing numbers when she gets k or more points.\n\nReturn the probability that Alice has n or fewer points.\n\nAnswers within 10^-5 of the actual answer are considered accepted.\n\nExample 1:\n\nInput: n = 10, k = 1, maxPts = 10\nOutput: 1.00000\nExplanation: Alice gets a single card, then stops.\n\nExample 2:\n\nInput: n = 6, k = 1, maxPts = 10\nOutput: 0.60000\nExplanation: Alice gets a single card, then stops.\nIn 6 out of 10 possibilities, she is at or below 6 points.\n\nExample 3:\n\nInput: n = 21, k = 17, maxPts = 10\nOutput: 0.73278\n\nConstraints:\n\n- 0 <= k <= n <= 10^4\n- 1 <= maxPts <= 10^4\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(n=10, k=5, maxPts=5), 1.0)\n assert answers_match(candidate(n=100, k=50, maxPts=20), 1.0)\n assert answers_match(candidate(n=100, k=50, maxPts=5), 1.0)\n assert answers_match(candidate(n=6, k=1, maxPts=10), 0.6)\n assert answers_match(candidate(n=10000, k=0, maxPts=10000), 1)\n assert answers_match(candidate(n=10, k=1, maxPts=10), 1.0)\n assert answers_match(candidate(n=21, k=17, maxPts=10), 0.7327777870686083)\n assert answers_match(candidate(n=20, k=15, maxPts=5), 1.0)\n assert answers_match(candidate(n=0, k=0, maxPts=1), 1)\n assert answers_match(candidate(n=100, k=90, maxPts=5), 1.0)\n assert answers_match(candidate(n=5, k=3, maxPts=2), 1.0)\n assert answers_match(candidate(n=20, k=0, maxPts=10), 1)\n assert answers_match(candidate(n=15, k=15, maxPts=10), 0.18009983358324094)\n assert answers_match(candidate(n=75, k=50, maxPts=20), 1.0)\n assert answers_match(candidate(n=25, k=25, maxPts=5), 0.3333044673513253)\n assert answers_match(candidate(n=100, k=100, maxPts=1), 1.0)\n assert answers_match(candidate(n=100, k=50, maxPts=50), 1.0)\n assert answers_match(candidate(n=30, k=25, maxPts=5), 1.0)\n assert answers_match(candidate(n=200, k=150, maxPts=50), 1.0)\n assert answers_match(candidate(n=75, k=30, maxPts=30), 1.0)\n assert answers_match(candidate(n=9999, k=0, maxPts=100), 1)\n assert answers_match(candidate(n=45, k=45, maxPts=10), 0.18183615529245928)\n assert answers_match(candidate(n=50, k=30, maxPts=20), 1.0)\n assert answers_match(candidate(n=100, k=80, maxPts=20), 1.0)\n assert answers_match(candidate(n=500, k=400, maxPts=50), 1.0)\n assert answers_match(candidate(n=50, k=40, maxPts=10), 1.0)\n assert answers_match(candidate(n=60, k=55, maxPts=10), 0.818177813346613)\n assert answers_match(candidate(n=60, k=30, maxPts=10), 1.0)\n assert answers_match(candidate(n=100, k=0, maxPts=1), 1)\n assert answers_match(candidate(n=200, k=150, maxPts=30), 1.0)\n assert answers_match(candidate(n=15, k=10, maxPts=5), 1.0)\n assert answers_match(candidate(n=100, k=50, maxPts=25), 1.0)\n assert answers_match(candidate(n=50, k=25, maxPts=20), 1.0)\n assert answers_match(candidate(n=80, k=40, maxPts=15), 1.0)\n assert answers_match(candidate(n=80, k=70, maxPts=10), 1.0)\n assert answers_match(candidate(n=90, k=85, maxPts=5), 1.0)\n assert answers_match(candidate(n=750, k=300, maxPts=50), 1.0)\n assert answers_match(candidate(n=30, k=25, maxPts=10), 0.8193954028011721)\n assert answers_match(candidate(n=500, k=250, maxPts=100), 1.0)\n assert answers_match(candidate(n=15, k=7, maxPts=5), 1.0)\n assert answers_match(candidate(n=80, k=20, maxPts=3), 1.0)\n assert answers_match(candidate(n=15, k=15, maxPts=1), 1.0)\n assert answers_match(candidate(n=80, k=60, maxPts=10), 1.0)\n assert answers_match(candidate(n=25, k=25, maxPts=1), 1.0)\n assert answers_match(candidate(n=25, k=0, maxPts=25), 1)\n assert answers_match(candidate(n=300, k=1, maxPts=100), 1.0)\n assert answers_match(candidate(n=30, k=20, maxPts=10), 1.0)\n assert answers_match(candidate(n=25, k=20, maxPts=15), 0.6217079716932831)\n assert answers_match(candidate(n=25, k=20, maxPts=5), 1.0)\n assert answers_match(candidate(n=120, k=90, maxPts=20), 1.0)\n assert answers_match(candidate(n=70, k=60, maxPts=3), 1.0)\n assert answers_match(candidate(n=15, k=10, maxPts=3), 1.0)\n assert answers_match(candidate(n=90, k=75, maxPts=12), 1.0)\n assert answers_match(candidate(n=50, k=25, maxPts=5), 1.0)\n assert answers_match(candidate(n=75, k=50, maxPts=25), 1.0)\n assert answers_match(candidate(n=40, k=0, maxPts=5), 1)\n assert answers_match(candidate(n=200, k=150, maxPts=10), 1.0)\n assert answers_match(candidate(n=70, k=10, maxPts=30), 1.0)\n assert answers_match(candidate(n=150, k=100, maxPts=15), 1.0)\n assert answers_match(candidate(n=30, k=15, maxPts=10), 1.0)\n assert answers_match(candidate(n=100, k=90, maxPts=10), 1.0)\n assert answers_match(candidate(n=30, k=15, maxPts=5), 1.0)\n assert answers_match(candidate(n=90, k=80, maxPts=5), 1.0)\n", "comparison": "float"}, "public_tests": ["10\n1\n10", "6\n1\n10", "21\n17\n10"], "hints": [], "metadata": {"canonical_parameter_names": ["n", "k", "maxPts"], "leetcode_dataset_entry_point": "Solution().new21Game", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:28+00:00", "tests_total": 63, "tests_dropped": 0, "flags": ["decimal_answer"], "topic_tags": ["math", "dynamic-programming", "sliding-window", "probability-and-statistics"]}, "language": "java", "interface": {"raw_signature": "public double new21Game(int n, int k, int maxPts) {", "container": "Solution", "callable": "new21Game", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}, {"name": "maxPts", "type": "int"}], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 838, "task_id": "push-dominoes", "difficulty": "Medium", "problem_description": "There are n dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to the left or to the right.\n\nAfter each second, each domino that is falling to the left pushes the adjacent domino on the left. Similarly, the dominoes falling to the right push their adjacent dominoes standing on the right.\n\nWhen a vertical domino has dominoes falling on it from both sides, it stays still due to the balance of the forces.\n\nFor the purposes of this question, we will consider that a falling domino expends no additional force to a falling or already fallen domino.\n\nYou are given a string dominoes representing the initial state where:\n\n- dominoes[i] = 'L', if the i^th domino has been pushed to the left,\n- dominoes[i] = 'R', if the i^th domino has been pushed to the right, and\n- dominoes[i] = '.', if the i^th domino has not been pushed.\n\nReturn a string representing the final state.\n\nExample 1:\n\nInput: dominoes = \"RR.L\"\nOutput: \"RR.L\"\nExplanation: The first domino expends no additional force on the second domino.\n\nExample 2:\n\nInput: dominoes = \".L.R...LR..L..\"\nOutput: \"LL.RR.LLRRLL..\"\n\nConstraints:\n\n- n == dominoes.length\n- 1 <= n <= 10^5\n- dominoes[i] is either 'L', 'R', or '.'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(dominoes = \"R..L\") == \"RRLL\"\n assert candidate(dominoes = \"..R......L..\") == \"..RRRRLLLL..\"\n assert candidate(dominoes = \"RRRRRRRRRR\") == \"RRRRRRRRRR\"\n assert candidate(dominoes = \"L........R\") == \"L........R\"\n assert candidate(dominoes = \"L.R...R.L\") == \"L.RRRRR.L\"\n assert candidate(dominoes = \"LLLLL\") == \"LLLLL\"\n assert candidate(dominoes = \"LLRRLLRRLL\") == \"LLRRLLRRLL\"\n assert candidate(dominoes = \"LLLLLLLLLL\") == \"LLLLLLLLLL\"\n assert candidate(dominoes = \"LLRRLLRR\") == \"LLRRLLRR\"\n assert candidate(dominoes = \"RRRRR\") == \"RRRRR\"\n assert candidate(dominoes = \".L.R...LR..L..\") == \"LL.RR.LLRRLL..\"\n assert candidate(dominoes = \"........\") == \"........\"\n assert candidate(dominoes = \"R........\") == \"RRRRRRRRR\"\n assert candidate(dominoes = \"RRRRRRRRR\") == \"RRRRRRRRR\"\n assert candidate(dominoes = \"R....L\") == \"RRRLLL\"\n assert candidate(dominoes = \"L.L.L\") == \"LLLLL\"\n assert candidate(dominoes = \"R.L.R.L.R\") == \"R.L.R.L.R\"\n assert candidate(dominoes = \"R......L\") == \"RRRRLLLL\"\n assert candidate(dominoes = \"L.R.L\") == \"L.R.L\"\n assert candidate(dominoes = \"LR.LR.LR.LR\") == \"LR.LR.LR.LR\"\n assert candidate(dominoes = \"R........L\") == \"RRRRRLLLLL\"\n assert candidate(dominoes = \".....\") == \".....\"\n assert candidate(dominoes = \"R.R.L.L.R\") == \"RRR.LLL.R\"\n assert candidate(dominoes = \"R......R.L\") == \"RRRRRRRR.L\"\n assert candidate(dominoes = \"RR.L\") == \"RR.L\"\n assert candidate(dominoes = \"L.R.R.L.L.R.L.R.L.L.R.L.R.L.L.R.L.R.L\") == \"L.RRR.LLL.R.L.R.LLL.R.L.R.LLL.R.L.R.L\"\n assert candidate(dominoes = \"........L\") == \"LLLLLLLLL\"\n assert candidate(dominoes = \"RLRLRLRL\") == \"RLRLRLRL\"\n assert candidate(dominoes = \"R.....L\") == \"RRR.LLL\"\n assert candidate(dominoes = \"R.R.L\") == \"RRR.L\"\n assert candidate(dominoes = \"L.R.L.R.L\") == \"L.R.L.R.L\"\n assert candidate(dominoes = \".......\") == \".......\"\n assert candidate(dominoes = \"L.R.R.L.L.R\") == \"L.RRR.LLL.R\"\n assert candidate(dominoes = \"LLLLLLLLL\") == \"LLLLLLLLL\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L\") == \"L.R.L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"............R.L...........\") == \"............R.L...........\"\n assert candidate(dominoes = \"R.....L.....R.....L\") == \"RRR.LLL.....RRR.LLL\"\n assert candidate(dominoes = \"L...R...L...R...L\") == \"L...RR.LL...RR.LL\"\n assert candidate(dominoes = \"L...R.L...R.L...R.L\") == \"L...R.L...R.L...R.L\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\") == \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\") == \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"R......L.R.L......R\") == \"RRRRLLLL.R.L......R\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.R\") == \"L.R.L.R.L.R.L.RRR\"\n assert candidate(dominoes = \"L.....R.L.....R.L.....R\") == \"L.....R.L.....R.L.....R\"\n assert candidate(dominoes = \"...R...L...R...L...\") == \"...RR.LL...RR.LL...\"\n assert candidate(dominoes = \"R...L...R...L...R...L\") == \"RR.LL...RR.LL...RR.LL\"\n assert candidate(dominoes = \"R.L.R.L.R.L\") == \"R.L.R.L.R.L\"\n assert candidate(dominoes = \".......L........R\") == \"LLLLLLLL........R\"\n assert candidate(dominoes = \"R...L.L...R.R...L\") == \"RR.LLLL...RRRR.LL\"\n assert candidate(dominoes = \"L.L.L.L.L.L.L.L.L\") == \"LLLLLLLLLLLLLLLLL\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"R.R.R.R.R.R.R.L.L.L.L.L\") == \"RRRRRRRRRRRRR.LLLLLLLLL\"\n assert candidate(dominoes = \"...R.L.L.R.L.L.R.L...\") == \"...R.LLL.R.LLL.R.L...\"\n assert candidate(dominoes = \"LLLLLLLLLLRRRRRRRRRR\") == \"LLLLLLLLLLRRRRRRRRRR\"\n assert candidate(dominoes = \"L........R........L\") == \"L........RRRRRLLLLL\"\n assert candidate(dominoes = \"L......R.R......L.L......R\") == \"L......RRRRRRLLLLLL......R\"\n assert candidate(dominoes = \"L.R.R.L.L.R.R.L.L\") == \"L.RRR.LLL.RRR.LLL\"\n assert candidate(dominoes = \"R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R\") == \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R\") == \"L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.R.L\") == \"L.R.L.R.L.R.L.RRR.L\"\n assert candidate(dominoes = \"R.......L.L.......R.R.......L\") == \"RRRR.LLLLLL.......RRRRRR.LLLL\"\n assert candidate(dominoes = \"L.R.R...L.R.L.R.L\") == \"L.RRRR.LL.R.L.R.L\"\n assert candidate(dominoes = \"RL.R.L.RL.R.L.RL\") == \"RL.R.L.RL.R.L.RL\"\n assert candidate(dominoes = \"R.R.R.R.R.R.R.R\") == \"RRRRRRRRRRRRRRR\"\n assert candidate(dominoes = \"RLRLRLRLRLRLRLRLRL\") == \"RLRLRLRLRLRLRLRLRL\"\n assert candidate(dominoes = \"R....L.R.L....L\") == \"RRRLLL.R.LLLLLL\"\n assert candidate(dominoes = \"RRRR.L.L.R..L.RR.L\") == \"RRRR.LLL.RRLL.RR.L\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.L\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.LLL\"\n assert candidate(dominoes = \"R.L...L.R.R...L.L.R.L...L\") == \"R.LLLLL.RRRR.LLLL.R.LLLLL\"\n assert candidate(dominoes = \"RR.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\") == \"RR.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"R.....L.R.....L.R.....L\") == \"RRR.LLL.RRR.LLL.RRR.LLL\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"R...L.R...L\") == \"RR.LL.RR.LL\"\n assert candidate(dominoes = \"R.........L\") == \"RRRRR.LLLLL\"\n assert candidate(dominoes = \"R...............................L\") == \"RRRRRRRRRRRRRRRR.LLLLLLLLLLLLLLLL\"\n assert candidate(dominoes = \"R...L.R...L.R...L.R.L\") == \"RR.LL.RR.LL.RR.LL.R.L\"\n assert candidate(dominoes = \"L.L.L.L.L.L.L.L.L.L\") == \"LLLLLLLLLLLLLLLLLLL\"\n assert candidate(dominoes = \"LLRRRR.LLLLLRRR.L.L.L.L.L.R\") == \"LLRRRR.LLLLLRRR.LLLLLLLLL.R\"\n assert candidate(dominoes = \"RRRRRR.....LLLLL\") == \"RRRRRRRR.LLLLLLL\"\n assert candidate(dominoes = \".......R.L.......\") == \".......R.L.......\"\n assert candidate(dominoes = \"..R.L..R.L..R.L..\") == \"..R.L..R.L..R.L..\"\n assert candidate(dominoes = \"......R.L......\") == \"......R.L......\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"RR.LL.RR.LL.RR.LL\") == \"RR.LL.RR.LL.RR.LL\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L\") == \"R.L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"RR...L.L.L.R...RR\") == \"RRR.LLLLLL.RRRRRR\"\n assert candidate(dominoes = \"LRLRLRLRLRLRLRLRLR\") == \"LRLRLRLRLRLRLRLRLR\"\n assert candidate(dominoes = \"R.L.L.L.L.L.L.L.L.L.R\") == \"R.LLLLLLLLLLLLLLLLL.R\"\n assert candidate(dominoes = \"RR.LLLLLRRRR.LLLLLRRRR.LLLLL\") == \"RR.LLLLLRRRR.LLLLLRRRR.LLLLL\"\n assert candidate(dominoes = \"L.L.L.L.L.R.R.R.R.R\") == \"LLLLLLLLL.RRRRRRRRR\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.L\") == \"L.R.L.R.L.R.L.R.L.R.LLL\"\n assert candidate(dominoes = \"L...R...L...R...L...R\") == \"L...RR.LL...RR.LL...R\"\n assert candidate(dominoes = \"RR.LRR.LRR.LRR.L\") == \"RR.LRR.LRR.LRR.L\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\") == \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"...R.L...L.R...R.L...\") == \"...R.LLLLL.RRRRR.L...\"\n assert candidate(dominoes = \"........L...R\") == \"LLLLLLLLL...R\"\n assert candidate(dominoes = \"L...R.L...R.L...R.L...R.L...R.L...R.L...R.L...R.L...R.L\") == \"L...R.L...R.L...R.L...R.L...R.L...R.L...R.L...R.L...R.L\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.L\") == \"R.L.R.L.R.L.R.LLL\"\n assert candidate(dominoes = \"R.L....L.R.R.L\") == \"R.LLLLLL.RRR.L\"\n assert candidate(dominoes = \"L.L.R.R.L.L.R.R.L.L\") == \"LLL.RRR.LLL.RRR.LLL\"\n assert candidate(dominoes = \"L.L.L.L.L.L.L.L\") == \"LLLLLLLLLLLLLLL\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"R......L.L......R.R......L\") == \"RRRRLLLLLL......RRRRRRLLLL\"\n assert candidate(dominoes = \".......................................\") == \".......................................\"\n assert candidate(dominoes = \"L.L.L.L.L.L.R.R.R.R.R\") == \"LLLLLLLLLLL.RRRRRRRRR\"\n assert candidate(dominoes = \"....R.L.....R.L....\") == \"....R.L.....R.L....\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.L.R.L\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.LLL.R.L\"\n assert candidate(dominoes = \"RRRRLLLLLLLL\") == \"RRRRLLLLLLLL\"\n assert candidate(dominoes = \"L...R.L...R.L...R\") == \"L...R.L...R.L...R\"\n assert candidate(dominoes = \"RRRRRRRRRRLLLLLLLLLL\") == \"RRRRRRRRRRLLLLLLLLLL\"\n assert candidate(dominoes = \"RRRR.LLLLL.LLLLL.RRRR\") == \"RRRR.LLLLLLLLLLL.RRRR\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\") == \"L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"L.....R.R...L.L.R.L\") == \"L.....RRRR.LLLL.R.L\"\n assert candidate(dominoes = \"R........L.......\") == \"RRRRRLLLLL.......\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R\") == \"R.L.R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.L.R.L\") == \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.LLL.R.L\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R.L\") == \"R.L.R.L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"L.....R.....L.....R\") == \"L.....RRR.LLL.....R\"\n assert candidate(dominoes = \"LR.LR.LR.LR.LR.LR\") == \"LR.LR.LR.LR.LR.LR\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R\") == \"R.L.R.L.R.L.R.L.R\"\n assert candidate(dominoes = \"L.R.R.L.L.R.R.L.L.R\") == \"L.RRR.LLL.RRR.LLL.R\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.L.R\") == \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.LLL.R\"\n assert candidate(dominoes = \"........L...R........\") == \"LLLLLLLLL...RRRRRRRRR\"\n assert candidate(dominoes = \"R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R\") == \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.L.R\") == \"R.L.R.L.R.L.R.LLL.R\"\n assert candidate(dominoes = \"........L.R........\") == \"LLLLLLLLL.RRRRRRRRR\"\n assert candidate(dominoes = \"..............R..............L..............\") == \"..............RRRRRRRRLLLLLLLL..............\"\n assert candidate(dominoes = \"R.R.R.R.R.L.L.L.L.L\") == \"RRRRRRRRR.LLLLLLLLL\"\n assert candidate(dominoes = \".RR.L.L.R.R.L.L\") == \".RR.LLL.RRR.LLL\"\n assert candidate(dominoes = \"L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L\") == \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\"\n assert candidate(dominoes = \"R.L...........R\") == \"R.L...........R\"\n assert candidate(dominoes = \"..............................\") == \"..............................\"\n assert candidate(dominoes = \"LRR.LL.R..R.L.L...R\") == \"LRR.LL.RRRR.LLL...R\"\n assert candidate(dominoes = \"R.R.R.R.R.R.R.R.R.R\") == \"RRRRRRRRRRRRRRRRRRR\"\n assert candidate(dominoes = \"LLLLL.....RRRRR\") == \"LLLLL.....RRRRR\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\") == \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"R.L...R...L...R.L\") == \"R.L...RR.LL...R.L\"\n assert candidate(dominoes = \"R.R.R.R.R.R.R.R.R\") == \"RRRRRRRRRRRRRRRRR\"\n assert candidate(dominoes = \"R.R.R.R.R.R.R.R.R.R.R\") == \"RRRRRRRRRRRRRRRRRRRRR\"\n assert candidate(dominoes = \"...R.L.R.L.R.L.R.L.R.L...\") == \"...R.L.R.L.R.L.R.L.R.L...\"\n assert candidate(dominoes = \"........LR........\") == \"LLLLLLLLLRRRRRRRRR\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L\") == \"R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"..R...L...R...L...R\") == \"..RR.LL...RR.LL...R\"\n assert candidate(dominoes = \"RR.L.L.R.R.L.L.R\") == \"RR.LLL.RRR.LLL.R\"\n assert candidate(dominoes = \"R.L....R.L\") == \"R.L....R.L\"\n assert candidate(dominoes = \"L.L.L.L.L.L.L.L.L.L.L\") == \"LLLLLLLLLLLLLLLLLLLLL\"\n assert candidate(dominoes = \"RR.R.L.LRR\") == \"RRRR.LLLRR\"\n assert candidate(dominoes = \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\") == \"R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"R....L.R.L.R....L\") == \"RRRLLL.R.L.RRRLLL\"\n assert candidate(dominoes = \"..R.R.L.L.R..L.L.R..\") == \"..RRR.LLL.RRLLLL.RRR\"\n assert candidate(dominoes = \"L.R...L...R...L\") == \"L.RR.LL...RR.LL\"\n assert candidate(dominoes = \"R.............L\") == \"RRRRRRR.LLLLLLL\"\n assert candidate(dominoes = \"R........L........R\") == \"RRRRRLLLLL........R\"\n assert candidate(dominoes = \"LLLLRRRRLLLLRRRRLLLLRRRRLLLL\") == \"LLLLRRRRLLLLRRRRLLLLRRRRLLLL\"\n assert candidate(dominoes = \"L...R...L...R.L\") == \"L...RR.LL...R.L\"\n assert candidate(dominoes = \"L.R.L.R.L.R.L.R.L\") == \"L.R.L.R.L.R.L.R.L\"\n assert candidate(dominoes = \"L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L\") == \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\"\n assert candidate(dominoes = \"L...R.L...R.L...R.L.R\") == \"L...R.L...R.L...R.L.R\"\n assert candidate(dominoes = \"L.R...R.L.L...R.R.L.L...R\") == \"L.RRRRR.LLL...RRR.LLL...R\"\n assert candidate(dominoes = \"L...R....L...R\") == \"L...RRRLLL...R\"\n", "comparison": "exact"}, "public_tests": ["\"RR.L\"", "\".L.R...LR..L..\""], "hints": [], "metadata": {"canonical_parameter_names": ["dominoes"], "leetcode_dataset_entry_point": "Solution().pushDominoes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:30+00:00", "tests_total": 162, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["two-pointers", "string", "dynamic-programming"]}, "language": "java", "interface": {"raw_signature": "public String pushDominoes(String dominoes) {", "container": "Solution", "callable": "pushDominoes", "parameters": [{"name": "dominoes", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 839, "task_id": "similar-string-groups", "difficulty": "Hard", "problem_description": "Two strings, X and Y, are considered similar if either they are identical or we can make them equivalent by swapping at most two letters (in distinct positions) within the string X.\n\nFor example, \"tars\" and \"rats\" are similar (swapping at positions 0 and 2), and \"rats\" and \"arts\" are similar, but \"star\" is not similar to \"tars\", \"rats\", or \"arts\".\n\nTogether, these form two connected groups by similarity: {\"tars\", \"rats\", \"arts\"} and {\"star\"}. Notice that \"tars\" and \"arts\" are in the same group even though they are not similar. Formally, each group is such that a word is in the group if and only if it is similar to at least one other word in the group.\n\nWe are given a list strs of strings where every string in strs is an anagram of every other string in strs. How many groups are there?\n\nExample 1:\n\nInput: strs = [\"tars\",\"rats\",\"arts\",\"star\"]\nOutput: 2\n\nExample 2:\n\nInput: strs = [\"omv\",\"ovm\"]\nOutput: 1\n\nConstraints:\n\n- 1 <= strs.length <= 300\n- 1 <= strs[i].length <= 300\n- strs[i] consists of lowercase letters only.\n- All words in strs have the same length and are anagrams of each other.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(strs = ['abc', 'bca', 'cab', 'cba', 'bac', 'acb']) == 1\n assert candidate(strs = ['ab', 'ba', 'abc', 'cab', 'bca']) == 1\n assert candidate(strs = ['aaaaa', 'aaabb', 'aaabc', 'aaaba', 'aaaaa']) == 1\n assert candidate(strs = ['tars', 'rats', 'arts', 'star']) == 2\n assert candidate(strs = ['abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba']) == 1\n assert candidate(strs = ['abc', 'bca', 'cab', 'cba', 'acb', 'bac']) == 1\n assert candidate(strs = ['abcde', 'edcba', 'abced', 'decba', 'decab']) == 2\n assert candidate(strs = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yzw']) == 9\n assert candidate(strs = ['omv', 'ovm']) == 1\n assert candidate(strs = ['kite', 'peek', 'pink', 'pite', 'side', 'like', 'pipe', 'pike', 'lipk', 'kite', 'tape', 'pelt', 'pite', 'pink', 'pite']) == 1\n assert candidate(strs = ['aaa', 'aab', 'aba', 'baa', 'abb', 'bba', 'bab', 'bba', 'bbb', 'bbb']) == 1\n assert candidate(strs = ['aaaaaa', 'aaaabb', 'aaaabc', 'aaaaba', 'aaaaaa']) == 1\n assert candidate(strs = ['abc', 'bca', 'cab', 'acb', 'bac', 'cba']) == 1\n assert candidate(strs = ['abcdef', 'bcdefa', 'cdefab', 'defabc', 'efabcd', 'fabcde']) == 6\n assert candidate(strs = ['abcde', 'edcba', 'abced', 'deabc', 'decab', 'cdeab']) == 5\n assert candidate(strs = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba']) == 1\n assert candidate(strs = ['a', 'a', 'a', 'a', 'a']) == 1\n assert candidate(strs = ['abcdefghijklmnopqrstuvwxyz', 'bcadefghijklmnopqrstuvwxyza', 'cdefghijklmnopqrstuvwxyzab']) == 3\n assert candidate(strs = ['aaaa', 'aada', 'aadaa', 'aadda', 'aaddd', 'adaaa', 'adaad', 'adaad', 'addaa', 'adada', 'adada', 'addaa', 'daaaa', 'daada', 'daada', 'dadaa', 'dadad', 'daada', 'dadaa', 'dadad', 'daada', 'ddaaa', 'ddada', 'ddaad', 'ddada', 'dddda']) == 1\n assert candidate(strs = ['zzzzzzzzzz', 'zzzzzzzzzy', 'zzzzzzzzzx', 'zzzzzzzzzw', 'zzzzzzzzzv', 'zzzzzzzzzu', 'zzzzzzzzzt', 'zzzzzzzzzs', 'zzzzzzzzzr', 'zzzzzzzzzq']) == 1\n assert candidate(strs = ['mnopqr', 'nopqmr', 'opqmnr', 'pqomnr', 'qpomnr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr', 'mnopqr']) == 3\n assert candidate(strs = ['abcde', 'edcba', 'abced', 'decba', 'decab', 'abcde', 'edcba', 'abced', 'decba', 'decab']) == 2\n assert candidate(strs = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij']) == 1\n assert candidate(strs = ['abcdefgh', 'bcdefgha', 'cdefghab', 'defghabc', 'efghabcd', 'fghabcde', 'ghabcdef', 'habcdefg']) == 8\n assert candidate(strs = ['zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz']) == 1\n assert candidate(strs = ['abcdeabcde', 'edcbaedcba', 'abcedabced', 'decbaedcba', 'decabdecab', 'abcdeabced', 'abcdeabcdx']) == 3\n assert candidate(strs = ['abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik', 'abcdefghik']) == 1\n assert candidate(strs = ['aabbcc', 'ccaabb', 'bbaacc', 'aabbbc', 'bcaabb', 'abcabc', 'babcac', 'cabcab', 'bacbac', 'acbacb', 'acbbac', 'abacbc', 'cababc', 'cbaabc', 'acabbc', 'bcabac', 'abcbac', 'cabbac', 'bcacab', 'acbbca']) == 1\n assert candidate(strs = ['qwertyuiop', 'qeywrtuiop', 'qwrtypuioe', 'qwertyuiop', 'qwertyuipo']) == 3\n assert candidate(strs = ['abcabcabcabc', 'cbacbacbacba', 'bacbacbacbac', 'abcabcabcacb', 'cbacbacbacac', 'bacbacbacabc', 'abcabcabcaba', 'cbacbacbacad', 'bacbacbacaba', 'abcabcabcaca', 'cbacbacbacad', 'bacbacbacaca', 'abcabcabacba', 'cbacbacbacba', 'bacbacbacacb', 'abcabcabcabc', 'cbacbacbacac', 'bacbacbacabc']) == 3\n assert candidate(strs = ['abacabad', 'babadaba', 'bacabada', 'acabadab', 'adabacab', 'cabadaba', 'abadabac', 'badabaca']) == 4\n assert candidate(strs = ['abcdefghij', 'abcdefghji', 'abcdefghif', 'abcdefghig', 'abcdefghih']) == 1\n assert candidate(strs = ['abcdefghij', 'abcdefghik', 'abcdefghil', 'abcdefghim', 'abcdefghin', 'abcdefghio']) == 1\n assert candidate(strs = ['xyzzxy', 'zyxzyx', 'zzzyxy', 'zyzzxz', 'xyzzzx', 'zyxzyy', 'zyzzxy', 'zyzzxy']) == 1\n assert candidate(strs = ['abcdefg', 'gfedcba', 'fedcbag', 'gabcdef', 'bacdefg', 'gfeabcd', 'bcdefga', 'gfabcde', 'gefedcb', 'defgabc', 'gdefcab', 'fgedcba', 'gfabced', 'gfadebc', 'gbafced', 'gfacedb', 'gfebacd', 'gfbaced', 'gfbcdea', 'gfbedac', 'gfeadcb', 'gfecdba', 'gfdbeca', 'gfdecba']) == 13\n assert candidate(strs = ['abcdefghij', 'abcdefghik', 'abcdefghil', 'abcdefghim', 'abcdefghin']) == 1\n assert candidate(strs = ['abcdefgh', 'abcdefgh', 'bcdefgha', 'cdefghab', 'defghabc', 'efghabcd', 'fghabcde', 'ghabcdef', 'habcdefg', 'abcdefgha', 'abcdefghb', 'abcdefghc', 'abcdefghd', 'abcdefghi', 'abcdefghj']) == 8\n assert candidate(strs = ['abcdefgh', 'abcdefgh', 'aefghbcd', 'bcdefgha', 'ghabcdef', 'hgfedcba', 'abcdefgh']) == 5\n assert candidate(strs = ['xyzxyz', 'yzxyxz', 'zxyxyz', 'xyxzyz', 'yxzxzy', 'zxzyxy', 'xzyzxy', 'zyxzyx']) == 6\n assert candidate(strs = ['abcde', 'abced', 'abdec', 'abdec', 'abced', 'abcde', 'abced', 'abdec', 'abced', 'abcde', 'abced', 'abdec', 'abced', 'abcde', 'abced', 'abdec', 'abced', 'abcde']) == 1\n assert candidate(strs = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'abcdefghik', 'abcdefghil', 'abcdefghij', 'abcdefghim', 'abcdefghij', 'abcdefghin', 'abcdefghio']) == 2\n assert candidate(strs = ['abcdefg', 'bacdefg', 'cbadefg', 'dcabefg', 'edcabfg', 'fedcabc', 'gfedcab', 'hgfedca']) == 6\n assert candidate(strs = ['abcdefghij', 'bacdefghij', 'cabdefghij', 'abcdfehgij', 'abcdefghij', 'abcdefghik', 'abcdefghji']) == 2\n assert candidate(strs = ['abcd', 'dcba', 'cdab', 'bacd', 'cabd', 'acdb', 'adcb', 'bcda', 'cdba', 'bdca', 'dacb', 'cadb', 'bdac', 'abcd', 'dcba', 'cdab', 'bacd', 'cabd', 'acdb', 'adcb', 'bcda', 'cdba', 'bdca', 'dacb', 'cadb', 'bdac']) == 1\n assert candidate(strs = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abc', 'acb', 'bac', 'bca', 'cab', 'cba']) == 1\n assert candidate(strs = ['aaaaabbbbb', 'aaaabbbbba', 'aaabbbbaaa', 'aabbbbaaaa', 'abbbbaaaaa', 'baaaaabbbb', 'baaaaabbbb', 'bbbbbaaaaa', 'bbbbbaaaab', 'bbbbbaaabb', 'bbbbbaabba', 'bbbbbaabbb', 'bbbbabbbbb', 'bbbbbaabaa', 'bbbbaabbbb', 'bbaaaaabbb', 'bbaaaabbbb', 'bbaaabbbbb', 'bbbaaaaabb', 'bbbaaaabbb', 'bbbaaabbbb', 'bbbbaaaabb', 'bbbbaaabbb', 'bbbbaabbbb', 'bbbbbaaaab', 'bbbbbaaabbb', 'bbbbbaabbb', 'bbbbabbbba', 'bbbbabbaaa', 'bbbbbaabaa', 'bbbbbaaabb', 'bbbbaaaaaa', 'bbbbaaaaba', 'bbbbaaabaa', 'bbbbaaabab', 'bbbbaaabra', 'bbbbbaaaaa', 'bbbbbaaaab', 'bbbbbaaaba', 'bbbbbaabaa', 'bbbbbaaabb']) == 1\n assert candidate(strs = ['abcd', 'acbd', 'adbc', 'cabd', 'dbca', 'dcba', 'dcab']) == 1\n assert candidate(strs = ['abababab', 'babababa', 'aabbaabb', 'bbaabbaa', 'abbaabba', 'baabbaab', 'abbaabba', 'baabbaab', 'bbaabbaa', 'aabbaabb', 'babababa', 'abababab']) == 6\n assert candidate(strs = ['lkjhgfedcba', 'lkjhgfedcba', 'lkjhgfedcba', 'lkjhgfedcba', 'lkjhgfedcba']) == 1\n assert candidate(strs = ['abcde', 'edcba', 'dbeca', 'decba', 'decab', 'cedab', 'aebcd', 'bcdea', 'debac', 'baced', 'acebd', 'bdeca', 'acdeb', 'bacde', 'abced', 'decba', 'edabc', 'abcde', 'acbde', 'baced', 'bcaed']) == 5\n assert candidate(strs = ['qwertyuiop', 'wertyuiopq', 'ertyuiopqw', 'rtyuiopqwe', 'tyuiopqrst', 'yuiopqrstu', 'uiopqrstuv', 'iopqrstuvw', 'opqrstuvwx', 'pqrstuvwxy', 'qrstuvwxyz', 'rstuvwxyzp', 'stuvwxyzpr', 'tuvwxyzprs', 'uvwxyzprst', 'vwxyzprstq', 'wxyzprstqu', 'xyzprstquv', 'yzprstquvx', 'zprstquvxy', 'prstquvxyz', 'rstquvxyza', 'stquvxyzab', 'tquvxyzabc', 'quvxyzabcd', 'uvxyzabcde', 'vxyzabcdef', 'xyzabcdefg', 'yzabcdefgq', 'zabcdefgqr', 'abcdefgqrs', 'bcdefgqrst', 'cdefgqrstu', 'defgqrstuv', 'efgqrstuvw', 'fgqrstuvwxyz', 'gqrstuvwxyzx', 'hqrstuvwxyzx', 'qrstuvwxyzxy', 'rstuvwxyzxyq', 'stuvwxyzxyqp', 'tuvwxyzxyqpr', 'uvwxyzxyqprs', 'vwxyzxyqprst', 'wxyzxyqprstu', 'xyzxyqprstuv', 'yzxyqprstuvw', 'zxyqprstuvwx', 'xyqprstuvwxy', 'yqprstuvwxyz', 'qprstuvwxyzx', 'prstuvwxyzxy', 'rstuvwxyzxyz', 'stuvwxyzxyza', 'tuvwxyzxyqza']) == 44\n assert candidate(strs = ['abcdefg', 'gfedcba', 'bacdefg', 'abcdefg', 'gfedcbx', 'abcdefg', 'gfedcbw']) == 2\n assert candidate(strs = ['aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa', 'aabbccddeeff', 'ffeeddccbaaa']) == 2\n assert candidate(strs = ['ababab', 'bababa', 'bbaaab', 'aababb', 'ababba', 'abbaab', 'aabbab', 'ababab', 'aabbaa']) == 1\n assert candidate(strs = ['aaaaaaaa', 'aaaaabaa', 'aaaabaab', 'aaabaaba', 'aabaaaba', 'abaabaaa', 'baaaaaab', 'baaabaaa', 'baabaaab', 'babaaaaa', 'abaaaaab', 'abaaabaa', 'abaabaab', 'baabaaba', 'aabaaaba', 'aaabaaba', 'baaabaaa', 'baaaaaab', 'abaaaaab', 'baaaabaa', 'aabaaaba', 'abaabaab', 'baabaaba', 'aabaaaba', 'baaaabaa', 'baaaaaab', 'abaaaaab', 'abaabaab', 'baabaaba', 'aabaaaba', 'baaaabaa', 'baaaaaab', 'abaaaaab', 'abaabaab', 'baabaaba', 'aabaaaba', 'baaaabaa', 'baaaaaab', 'abaaaaab']) == 1\n assert candidate(strs = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'ijhgfedcba', 'abcdefghij', 'jihgfedcba', 'abcdefghij', 'ijhgfedcba']) == 2\n assert candidate(strs = ['abacax', 'aacxab', 'abacax', 'bacaxa', 'cacxab', 'abcaxa']) == 3\n", "comparison": "exact"}, "public_tests": ["[\"tars\",\"rats\",\"arts\",\"star\"]", "[\"omv\",\"ovm\"]"], "hints": [], "metadata": {"canonical_parameter_names": ["strs"], "leetcode_dataset_entry_point": "Solution().numSimilarGroups", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:32+00:00", "tests_total": 57, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "string", "depth-first-search", "breadth-first-search", "union-find"]}, "language": "java", "interface": {"raw_signature": "public int numSimilarGroups(String[] strs) {", "container": "Solution", "callable": "numSimilarGroups", "parameters": [{"name": "strs", "type": "String[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} @@ -295,7 +295,7 @@ {"question_id": 1223, "task_id": "dice-roll-simulation", "difficulty": "Hard", "problem_description": "A die simulator generates a random number from 1 to 6 for each roll. You introduced a constraint to the generator such that it cannot roll the number i more than rollMax[i] (1-indexed) consecutive times.\n\nGiven an array of integers rollMax and an integer n, return the number of distinct sequences that can be obtained with exact n rolls. Since the answer may be too large, return it modulo 10^9 + 7.\n\nTwo sequences are considered different if at least one element differs from each other.\n\nExample 1:\n\nInput: n = 2, rollMax = [1,1,2,2,2,3]\nOutput: 34\nExplanation: There will be 2 rolls of die, if there are no constraints on the die, there are 6 * 6 = 36 possible combinations. In this case, looking at rollMax array, the numbers 1 and 2 appear at most once consecutively, therefore sequences (1,1) and (2,2) cannot occur, so the final answer is 36-2 = 34.\n\nExample 2:\n\nInput: n = 2, rollMax = [1,1,1,1,1,1]\nOutput: 30\n\nExample 3:\n\nInput: n = 3, rollMax = [1,1,1,2,2,3]\nOutput: 181\n\nConstraints:\n\n- 1 <= n <= 5000\n- rollMax.length == 6\n- 1 <= rollMax[i] <= 15\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,rollMax = [2, 2, 2, 2, 2, 2]) == 7200\n assert candidate(n = 1,rollMax = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(n = 1,rollMax = [15, 15, 15, 15, 15, 15]) == 6\n assert candidate(n = 10,rollMax = [2, 3, 4, 5, 6, 7]) == 58240426\n assert candidate(n = 2,rollMax = [1, 1, 2, 2, 2, 3]) == 34\n assert candidate(n = 2,rollMax = [1, 1, 1, 1, 1, 1]) == 30\n assert candidate(n = 5,rollMax = [1, 2, 3, 4, 5, 6]) == 6919\n assert candidate(n = 5,rollMax = [1, 1, 1, 1, 1, 1]) == 3750\n assert candidate(n = 4,rollMax = [1, 2, 3, 4, 5, 6]) == 1188\n assert candidate(n = 3,rollMax = [1, 1, 1, 2, 2, 3]) == 181\n assert candidate(n = 50,rollMax = [5, 5, 5, 5, 5, 5]) == 808684040\n assert candidate(n = 300,rollMax = [1, 1, 1, 15, 1, 15]) == 728503686\n assert candidate(n = 150,rollMax = [1, 2, 2, 3, 3, 4]) == 917820088\n assert candidate(n = 300,rollMax = [3, 3, 3, 3, 3, 3]) == 197968606\n assert candidate(n = 25,rollMax = [15, 14, 13, 12, 11, 10]) == 470351288\n assert candidate(n = 350,rollMax = [2, 3, 4, 5, 6, 7]) == 326686679\n assert candidate(n = 100,rollMax = [5, 5, 5, 5, 5, 5]) == 505697887\n assert candidate(n = 15,rollMax = [1, 1, 2, 2, 3, 3]) == 758892805\n assert candidate(n = 4,rollMax = [3, 2, 1, 2, 3, 4]) == 1176\n assert candidate(n = 150,rollMax = [5, 5, 5, 5, 5, 5]) == 488934088\n assert candidate(n = 10,rollMax = [1, 1, 1, 2, 3, 4]) == 27915907\n assert candidate(n = 50,rollMax = [2, 3, 4, 5, 6, 7]) == 197242731\n assert candidate(n = 10,rollMax = [2, 3, 1, 1, 4, 5]) == 36308544\n assert candidate(n = 50,rollMax = [3, 4, 5, 6, 7, 8]) == 753899520\n assert candidate(n = 400,rollMax = [1, 2, 1, 2, 1, 2]) == 987298539\n assert candidate(n = 200,rollMax = [2, 3, 4, 5, 6, 7]) == 221148447\n assert candidate(n = 50,rollMax = [1, 2, 1, 2, 1, 2]) == 825497499\n assert candidate(n = 50,rollMax = [1, 2, 3, 4, 5, 15]) == 992520282\n assert candidate(n = 200,rollMax = [2, 2, 2, 2, 2, 2]) == 818530237\n assert candidate(n = 10,rollMax = [1, 1, 1, 1, 1, 1]) == 11718750\n assert candidate(n = 100,rollMax = [10, 10, 10, 10, 10, 10]) == 568370197\n assert candidate(n = 30,rollMax = [1, 2, 1, 2, 1, 2]) == 679107530\n assert candidate(n = 100,rollMax = [1, 1, 2, 2, 3, 3]) == 12398650\n assert candidate(n = 100,rollMax = [1, 1, 1, 1, 1, 1]) == 776377743\n assert candidate(n = 400,rollMax = [15, 14, 13, 12, 11, 10]) == 379975553\n assert candidate(n = 20,rollMax = [5, 5, 5, 5, 5, 5]) == 703140572\n assert candidate(n = 100,rollMax = [1, 1, 2, 2, 3, 3]) == 12398650\n assert candidate(n = 20,rollMax = [2, 3, 4, 5, 6, 7]) == 412603689\n assert candidate(n = 400,rollMax = [4, 4, 4, 4, 4, 4]) == 418009264\n assert candidate(n = 150,rollMax = [7, 6, 5, 4, 3, 2]) == 3950632\n assert candidate(n = 40,rollMax = [3, 1, 2, 4, 1, 3]) == 255974937\n", "comparison": "exact"}, "public_tests": ["2\n[1,1,2,2,2,3]", "2\n[1,1,1,1,1,1]", "3\n[1,1,1,2,2,3]"], "hints": ["Think on Dynamic Programming.", "DP(pos, last) which means we are at the position pos having as last the last character seen."], "metadata": {"canonical_parameter_names": ["n", "rollMax"], "leetcode_dataset_entry_point": "Solution().dieSimulator", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:48+00:00", "tests_total": 41, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming"]}, "language": "java", "interface": {"raw_signature": "public int dieSimulator(int n, int[] rollMax) {", "container": "Solution", "callable": "dieSimulator", "parameters": [{"name": "n", "type": "int"}, {"name": "rollMax", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1224, "task_id": "maximum-equal-frequency", "difficulty": "Hard", "problem_description": "Given an array nums of positive integers, return the longest possible length of an array prefix of nums, such that it is possible to remove exactly one element from this prefix so that every number that has appeared in it will have the same number of occurrences.\n\nIf after removing one element there are no remaining elements, it's still considered that every appeared number has the same number of ocurrences (0).\n\nExample 1:\n\nInput: nums = [2,2,1,1,5,3,3,5]\nOutput: 7\nExplanation: For the subarray [2,2,1,1,5,3,3] of length 7, if we remove nums[4] = 5, we will get [2,2,1,1,3,3], so that each number will appear exactly twice.\n\nExample 2:\n\nInput: nums = [1,1,1,2,2,2,3,3,3,4,4,4,5]\nOutput: 13\n\nConstraints:\n\n- 2 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10, 1, 1, 1, 2, 2, 3]) == 7\n assert candidate(nums = [1, 2, 2, 2, 1, 1]) == 5\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10]) == 11\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 20\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4]) == 7\n assert candidate(nums = [10, 2, 8, 9, 3, 8, 1, 5, 2, 3, 7, 6]) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 21\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 19\n assert candidate(nums = [100000, 100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 12\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1]) == 11\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 5\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5]) == 13\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 17\n assert candidate(nums = [2, 2, 1, 1, 5, 3, 3, 5]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 11\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 5\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 41\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20]) == 21\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 21\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 9, 9, 9]) == 5\n assert candidate(nums = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60]) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6]) == 11\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 10\n assert candidate(nums = [2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 9\n assert candidate(nums = [10, 10, 10, 11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 7\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 30\n assert candidate(nums = [7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 25\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 7\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 28\n assert candidate(nums = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50]) == 5\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 15, 15, 15]) == 46\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]) == 5\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 25\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 29\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 40\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 32\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 5\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 8, 8]) == 7\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9]) == 19\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 22\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 39\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 30]) == 31\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 2, 2]) == 21\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 36\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11]) == 41\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 6, 5, 4, 3, 2, 1, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2]) == 31\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 31\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 21\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5]) == 9\n assert candidate(nums = [100000, 100000, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10]) == 31\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 27\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 41\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 25\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 33\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 16\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 21\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10]) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 28\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8]) == 5\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 21\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 7\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30]) == 59\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 21\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 11\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10]) == 21\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 22\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5]) == 21\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 16\n assert candidate(nums = [10, 20, 20, 10, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60]) == 9\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9]) == 7\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6, 6, 6, 6]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 21\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 7\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 9\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 17\n", "comparison": "exact"}, "public_tests": ["[2,2,1,1,5,3,3,5]", "[1,1,1,2,2,2,3,3,3,4,4,4,5]"], "hints": ["Keep track of the min and max frequencies.", "The number to be eliminated must have a frequency of 1, same as the others or the same +1."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxEqualFreq", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:50+00:00", "tests_total": 104, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table"]}, "language": "java", "interface": {"raw_signature": "public int maxEqualFreq(int[] nums) {", "container": "Solution", "callable": "maxEqualFreq", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1227, "task_id": "airplane-seat-assignment-probability", "difficulty": "Medium", "problem_description": "n passengers board an airplane with exactly n seats. The first passenger has lost the ticket and picks a seat randomly. But after that, the rest of the passengers will:\n\n- Take their own seat if it is still available, and\n- Pick other seats randomly when they find their seat occupied\n\nReturn the probability that the n^th person gets his own seat.\n\nExample 1:\n\nInput: n = 1\nOutput: 1.00000\nExplanation: The first person can only get the first seat.\n\nExample 2:\n\nInput: n = 2\nOutput: 0.50000\nExplanation: The second person has a probability of 0.5 to get the second seat (when first person gets the first seat).\n\nConstraints:\n\n- 1 <= n <= 10^5\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(n=3), 0.5)\n assert answers_match(candidate(n=100000), 0.5)\n assert answers_match(candidate(n=100), 0.5)\n assert answers_match(candidate(n=10000), 0.5)\n assert answers_match(candidate(n=2), 0.5)\n assert answers_match(candidate(n=1), 1)\n assert answers_match(candidate(n=1000), 0.5)\n assert answers_match(candidate(n=10), 0.5)\n assert answers_match(candidate(n=99999), 0.5)\n assert answers_match(candidate(n=2000), 0.5)\n assert answers_match(candidate(n=50000), 0.5)\n assert answers_match(candidate(n=50), 0.5)\n assert answers_match(candidate(n=5), 0.5)\n assert answers_match(candidate(n=10001), 0.5)\n assert answers_match(candidate(n=4), 0.5)\n assert answers_match(candidate(n=1001), 0.5)\n assert answers_match(candidate(n=101), 0.5)\n assert answers_match(candidate(n=20000), 0.5)\n assert answers_match(candidate(n=5000), 0.5)\n assert answers_match(candidate(n=20), 0.5)\n assert answers_match(candidate(n=9999), 0.5)\n assert answers_match(candidate(n=50001), 0.5)\n assert answers_match(candidate(n=2500), 0.5)\n assert answers_match(candidate(n=200), 0.5)\n assert answers_match(candidate(n=99998), 0.5)\n assert answers_match(candidate(n=500), 0.5)\n", "comparison": "float"}, "public_tests": ["1", "2"], "hints": ["Let f(n) denote the probability of the n-th person getting correct seat in n-person case, then: f(1) = 1 (base case, trivial) f(2) = 1/2 (also trivial)", "Try to calculate f(3), f(4), and f(5) using the base cases. What is the value of them? f(i) for i >= 2 will also be 1/2.", "Try to proof why f(i) = 1/2 for i >= 2."], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().nthPersonGetsNthSeat", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:13:52+00:00", "tests_total": 32, "tests_dropped": 6, "flags": ["decimal_answer"], "topic_tags": ["math", "dynamic-programming", "brainteaser", "probability-and-statistics"]}, "language": "java", "interface": {"raw_signature": "public double nthPersonGetsNthSeat(int n) {", "container": "Solution", "callable": "nthPersonGetsNthSeat", "parameters": [{"name": "n", "type": "int"}], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1232, "task_id": "check-if-it-is-a-straight-line", "difficulty": "Easy", "problem_description": "You are given an integer array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. Check if these points make a straight line in the XY plane.\n\nExample 1:\n\nInput: coordinates = [[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]]\nOutput: true\n\nExample 2:\n\nInput: coordinates = [[1,1],[2,2],[3,4],[4,5],[5,6],[7,7]]\nOutput: false\n\nConstraints:\n\n- 2 <= coordinates.length <= 1000\n- coordinates[i].length == 2\n- -10^4 <= coordinates[i][0], coordinates[i][1] <= 10^4\n- coordinates contains no duplicate point.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(coordinates = [[0, 0], [0, 1], [0, 2], [0, 3]]) == True\n assert candidate(coordinates = [[-10000, -10000], [0, 0], [10000, 10000]]) == True\n assert candidate(coordinates = [[-4, -3], [1, 0], [3, -1], [0, -1], [-5, 2]]) == False\n assert candidate(coordinates = [[0, 0], [5, 5], [10, 10], [15, 15]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 4]]) == False\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 5]]) == False\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 4], [4, 5], [5, 6], [7, 7]]) == False\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 2], [2, 3]]) == True\n assert candidate(coordinates = [[1, 2], [2, 1], [3, 0], [4, -1], [5, -2]]) == True\n assert candidate(coordinates = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3]]) == True\n assert candidate(coordinates = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]]) == True\n assert candidate(coordinates = [[0, 0], [1, 1], [2, 2], [3, 3]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [2, 3]]) == False\n assert candidate(coordinates = [[-4, -3], [-1, 1], [2, 5], [5, 9]]) == True\n assert candidate(coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == True\n assert candidate(coordinates = [[-1, -1], [0, 0], [1, 1], [2, 2]]) == True\n assert candidate(coordinates = [[0, 1], [1, 3], [-1, -1], [2, 5]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 6]]) == False\n assert candidate(coordinates = [[1, 2], [2, 3], [3, 5]]) == False\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 0], [2, 1], [3, 0]]) == False\n assert candidate(coordinates = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5]]) == True\n assert candidate(coordinates = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == True\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == True\n assert candidate(coordinates = [[10, 5], [15, 10], [20, 15], [25, 20]]) == True\n assert candidate(coordinates = [[10000, 10000], [5000, 5000], [0, 0]]) == True\n assert candidate(coordinates = [[2, 4], [2, 5], [2, 6]]) == True\n assert candidate(coordinates = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4]]) == True\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == True\n assert candidate(coordinates = [[5, -10], [10, -5], [15, 0], [20, 5], [25, 10]]) == True\n assert candidate(coordinates = [[-1, -2], [-2, -3], [-3, -4], [-4, -5], [-5, -6]]) == True\n assert candidate(coordinates = [[-10, 5], [-5, 10], [0, 15], [5, 20], [10, 25], [15, 30], [20, 35], [25, 40]]) == True\n assert candidate(coordinates = [[-2, -4], [-1, -2], [0, 0], [1, 2], [2, 4]]) == True\n assert candidate(coordinates = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]]) == True\n assert candidate(coordinates = [[1000, 2000], [2000, 4000], [3000, 6000], [4000, 8000], [5000, 10000]]) == True\n assert candidate(coordinates = [[10, 20], [20, 40], [30, 60], [40, 80], [50, 100], [60, 120]]) == True\n assert candidate(coordinates = [[1, 2], [2, 3], [4, 5], [5, 6], [7, 8], [8, 9], [10, 11]]) == True\n assert candidate(coordinates = [[-5, -20], [0, -10], [5, 0], [10, 10], [15, 20]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 8]]) == False\n assert candidate(coordinates = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]]) == True\n assert candidate(coordinates = [[-1, -2], [-2, -4], [-3, -6], [-4, -8], [-5, -10]]) == True\n assert candidate(coordinates = [[-10, 15], [-5, 10], [0, 5], [5, 0], [10, -5], [15, -10]]) == True\n assert candidate(coordinates = [[2, 2], [4, 4], [6, 6], [8, 8], [10, 10], [12, 12], [14, 14], [16, 16]]) == True\n assert candidate(coordinates = [[1, 3], [2, 5], [3, 7], [4, 9], [5, 11]]) == True\n assert candidate(coordinates = [[-2, 3], [-1, 4], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]]) == True\n assert candidate(coordinates = [[10000, 10000], [5000, 5000], [0, 0], [-5000, -5000], [-10000, -10000]]) == True\n assert candidate(coordinates = [[-20, -30], [-10, -15], [0, 0], [10, 15], [20, 30]]) == True\n assert candidate(coordinates = [[-5, 5], [-10, 10], [-15, 15], [-20, 20], [-25, 25], [-30, 30]]) == True\n assert candidate(coordinates = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15]]) == True\n assert candidate(coordinates = [[-5, -10], [0, 0], [5, 10], [10, 20], [15, 30]]) == True\n assert candidate(coordinates = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0]]) == True\n assert candidate(coordinates = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35]]) == True\n assert candidate(coordinates = [[-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3]]) == True\n assert candidate(coordinates = [[-2, 1], [-1, 3], [0, 5], [1, 7], [2, 9], [3, 11]]) == True\n assert candidate(coordinates = [[-4, -2], [-2, 0], [0, 2], [2, 4], [4, 6]]) == True\n assert candidate(coordinates = [[-100, 100], [-50, 150], [0, 200], [50, 250], [100, 300]]) == True\n assert candidate(coordinates = [[-2, 2], [0, 0], [2, -2], [4, -4], [6, -6]]) == True\n assert candidate(coordinates = [[-1, -2], [1, 0], [3, 2], [5, 4], [7, 6], [9, 8]]) == True\n assert candidate(coordinates = [[-10, 15], [-5, 10], [0, 5], [5, 0], [10, -5]]) == True\n assert candidate(coordinates = [[5, 0], [5, 1], [5, 2], [5, 3], [5, 4]]) == True\n assert candidate(coordinates = [[0, -10], [0, -5], [0, 0], [0, 5], [0, 10], [0, 15]]) == True\n assert candidate(coordinates = [[100, 200], [200, 400], [300, 600], [400, 800], [500, 1000]]) == True\n assert candidate(coordinates = [[0, 1], [1, 3], [2, 5], [3, 7], [4, 9]]) == True\n assert candidate(coordinates = [[-3, 7], [-2, 5], [-1, 3], [0, 1], [1, -1], [2, -3]]) == True\n assert candidate(coordinates = [[-1, -2], [1, 0], [3, 2], [5, 4], [7, 6], [9, 8], [11, 10]]) == True\n assert candidate(coordinates = [[-5, -5], [0, -2.5], [5, 0], [10, 2.5], [15, 5]]) == True\n assert candidate(coordinates = [[-500, 500], [-250, 750], [0, 1000], [250, 1250], [500, 1500]]) == True\n assert candidate(coordinates = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1]]) == True\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == True\n assert candidate(coordinates = [[-10, 0], [-5, 0], [0, 0], [5, 0], [10, 0], [15, 0]]) == True\n assert candidate(coordinates = [[-2, -1], [0, 0], [2, 1], [4, 2], [6, 3], [8, 4]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == True\n assert candidate(coordinates = [[-2, -3], [-1, -1], [0, 1], [1, 3], [2, 5], [3, 7]]) == True\n assert candidate(coordinates = [[-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3]]) == True\n assert candidate(coordinates = [[-100, 200], [-200, 400], [-300, 600], [-400, 800], [-500, 1000]]) == True\n assert candidate(coordinates = [[-5, -10], [0, 0], [5, 10], [10, 20], [15, 30]]) == True\n assert candidate(coordinates = [[-5, -10], [-4, -8], [-3, -6], [-2, -4], [-1, -2], [0, 0]]) == True\n assert candidate(coordinates = [[-5, -5], [0, 0], [5, 5], [10, 10], [15, 15], [20, 20]]) == True\n assert candidate(coordinates = [[-100, 100], [-50, 50], [0, 0], [50, -50], [100, -100]]) == True\n assert candidate(coordinates = [[-5, 5], [-4, 4], [-3, 3], [-2, 2], [-1, 1], [0, 0]]) == True\n assert candidate(coordinates = [[-100, -100], [-50, -50], [0, 0], [50, 50], [100, 100]]) == True\n assert candidate(coordinates = [[-5, 5], [0, 10], [5, 15], [10, 20], [15, 25], [20, 30], [25, 35]]) == True\n assert candidate(coordinates = [[100, -200], [200, -400], [300, -600], [400, -800], [500, -1000]]) == True\n assert candidate(coordinates = [[1, 3], [2, 5], [3, 7], [4, 9], [5, 11], [6, 13], [7, 15], [8, 17], [9, 19], [10, 21]]) == True\n assert candidate(coordinates = [[-1, -2], [-2, -4], [-3, -6], [-4, -8], [-5, -10]]) == True\n assert candidate(coordinates = [[100, 100], [200, 200], [300, 300], [400, 401], [500, 500]]) == False\n assert candidate(coordinates = [[-100, 100], [100, -100], [0, 0]]) == True\n assert candidate(coordinates = [[2, 3], [4, 6], [6, 9], [8, 12], [10, 15]]) == True\n assert candidate(coordinates = [[-3, 3], [-6, 6], [-9, 9], [-12, 12], [-15, 15]]) == True\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 0], [0, -1], [-1, 0]]) == False\n assert candidate(coordinates = [[-10, -20], [0, 0], [10, 20], [20, 40], [30, 60]]) == True\n assert candidate(coordinates = [[1, 1], [3, 5], [5, 9], [7, 13], [9, 17]]) == True\n assert candidate(coordinates = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10]]) == True\n assert candidate(coordinates = [[-1, -5], [0, -2], [1, 1], [2, 4], [3, 7], [4, 10]]) == True\n assert candidate(coordinates = [[0, 1000], [1000, 1000], [2000, 1000], [3000, 1000], [4000, 1000]]) == True\n assert candidate(coordinates = [[-2, -3], [-1, -1], [0, 1], [1, 3], [2, 5]]) == True\n assert candidate(coordinates = [[1, 2], [2, 4], [4, 8], [8, 16], [16, 32], [32, 64]]) == True\n assert candidate(coordinates = [[-100, -200], [-200, -400], [-300, -600], [-400, -800], [-500, -1000]]) == True\n assert candidate(coordinates = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14]]) == True\n assert candidate(coordinates = [[1, 2], [4, 6], [7, 10], [10, 14], [13, 18], [16, 22], [19, 26]]) == True\n assert candidate(coordinates = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == True\n assert candidate(coordinates = [[-3, -6], [1, -2], [5, 2], [7, 3]]) == False\n assert candidate(coordinates = [[-100, 0], [0, 0], [100, 0], [200, 0], [300, 0]]) == True\n assert candidate(coordinates = [[-1000, 2000], [0, 0], [1000, -2000]]) == True\n assert candidate(coordinates = [[-5, -10], [0, 0], [5, 10], [10, 20], [15, 30], [20, 40]]) == True\n assert candidate(coordinates = [[-10, 0], [0, 5], [10, 10], [20, 15], [30, 20], [40, 25], [50, 30], [60, 35]]) == True\n assert candidate(coordinates = [[-1, 1], [0, 0], [1, -1], [2, -2], [3, -3]]) == True\n assert candidate(coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == True\n assert candidate(coordinates = [[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10]]) == True\n assert candidate(coordinates = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]]) == True\n assert candidate(coordinates = [[-10, -10], [-5, -5], [0, 0], [5, 5], [10, 10]]) == True\n assert candidate(coordinates = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]) == True\n assert candidate(coordinates = [[0, 1], [1, 2], [2, 3], [3, 5], [4, 6], [5, 8]]) == False\n assert candidate(coordinates = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 15]]) == False\n assert candidate(coordinates = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80]]) == True\n assert candidate(coordinates = [[-1, -1], [1, 1], [3, 3], [5, 5], [7, 7], [9, 9]]) == True\n assert candidate(coordinates = [[-1000, 0], [-500, 0], [0, 0], [500, 0], [1000, 0]]) == True\n assert candidate(coordinates = [[-10000, 10000], [-5000, 10000], [0, 10000], [5000, 10000], [10000, 10000]]) == True\n assert candidate(coordinates = [[5, 3], [10, 6], [15, 9], [20, 12], [25, 15]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 3], [5, 5]]) == False\n assert candidate(coordinates = [[-2, 4], [-1, 2], [0, 0], [1, -2], [2, -4]]) == True\n assert candidate(coordinates = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == True\n", "comparison": "exact"}, "public_tests": ["[[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]]", "[[1,1],[2,2],[3,4],[4,5],[5,6],[7,7]]"], "hints": ["If there're only 2 points, return true.", "Check if all other points lie on the line defined by the first 2 points.", "Use cross product to check collinearity."], "metadata": {"canonical_parameter_names": ["coordinates"], "leetcode_dataset_entry_point": "Solution().checkStraightLine", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:03+00:00", "tests_total": 125, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["array", "math", "geometry"]}, "language": "java", "interface": {"raw_signature": "public boolean checkStraightLine(int[][] coordinates) {", "container": "Solution", "callable": "checkStraightLine", "parameters": [{"name": "coordinates", "type": "int[][]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1232, "task_id": "check-if-it-is-a-straight-line", "difficulty": "Easy", "problem_description": "You are given an integer array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. Check if these points make a straight line in the XY plane.\n\nExample 1:\n\nInput: coordinates = [[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]]\nOutput: true\n\nExample 2:\n\nInput: coordinates = [[1,1],[2,2],[3,4],[4,5],[5,6],[7,7]]\nOutput: false\n\nConstraints:\n\n- 2 <= coordinates.length <= 1000\n- coordinates[i].length == 2\n- -10^4 <= coordinates[i][0], coordinates[i][1] <= 10^4\n- coordinates contains no duplicate point.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(coordinates = [[0, 0], [0, 1], [0, 2], [0, 3]]) == True\n assert candidate(coordinates = [[-10000, -10000], [0, 0], [10000, 10000]]) == True\n assert candidate(coordinates = [[-4, -3], [1, 0], [3, -1], [0, -1], [-5, 2]]) == False\n assert candidate(coordinates = [[0, 0], [5, 5], [10, 10], [15, 15]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 4]]) == False\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 5]]) == False\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 4], [4, 5], [5, 6], [7, 7]]) == False\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 2], [2, 3]]) == True\n assert candidate(coordinates = [[1, 2], [2, 1], [3, 0], [4, -1], [5, -2]]) == True\n assert candidate(coordinates = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3]]) == True\n assert candidate(coordinates = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]]) == True\n assert candidate(coordinates = [[0, 0], [1, 1], [2, 2], [3, 3]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [2, 3]]) == False\n assert candidate(coordinates = [[-4, -3], [-1, 1], [2, 5], [5, 9]]) == True\n assert candidate(coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == True\n assert candidate(coordinates = [[-1, -1], [0, 0], [1, 1], [2, 2]]) == True\n assert candidate(coordinates = [[0, 1], [1, 3], [-1, -1], [2, 5]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 6]]) == False\n assert candidate(coordinates = [[1, 2], [2, 3], [3, 5]]) == False\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 0], [2, 1], [3, 0]]) == False\n assert candidate(coordinates = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5]]) == True\n assert candidate(coordinates = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == True\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == True\n assert candidate(coordinates = [[10, 5], [15, 10], [20, 15], [25, 20]]) == True\n assert candidate(coordinates = [[10000, 10000], [5000, 5000], [0, 0]]) == True\n assert candidate(coordinates = [[2, 4], [2, 5], [2, 6]]) == True\n assert candidate(coordinates = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4]]) == True\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == True\n assert candidate(coordinates = [[5, -10], [10, -5], [15, 0], [20, 5], [25, 10]]) == True\n assert candidate(coordinates = [[-1, -2], [-2, -3], [-3, -4], [-4, -5], [-5, -6]]) == True\n assert candidate(coordinates = [[-10, 5], [-5, 10], [0, 15], [5, 20], [10, 25], [15, 30], [20, 35], [25, 40]]) == True\n assert candidate(coordinates = [[-2, -4], [-1, -2], [0, 0], [1, 2], [2, 4]]) == True\n assert candidate(coordinates = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]]) == True\n assert candidate(coordinates = [[1000, 2000], [2000, 4000], [3000, 6000], [4000, 8000], [5000, 10000]]) == True\n assert candidate(coordinates = [[10, 20], [20, 40], [30, 60], [40, 80], [50, 100], [60, 120]]) == True\n assert candidate(coordinates = [[1, 2], [2, 3], [4, 5], [5, 6], [7, 8], [8, 9], [10, 11]]) == True\n assert candidate(coordinates = [[-5, -20], [0, -10], [5, 0], [10, 10], [15, 20]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 8]]) == False\n assert candidate(coordinates = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]]) == True\n assert candidate(coordinates = [[-1, -2], [-2, -4], [-3, -6], [-4, -8], [-5, -10]]) == True\n assert candidate(coordinates = [[-10, 15], [-5, 10], [0, 5], [5, 0], [10, -5], [15, -10]]) == True\n assert candidate(coordinates = [[2, 2], [4, 4], [6, 6], [8, 8], [10, 10], [12, 12], [14, 14], [16, 16]]) == True\n assert candidate(coordinates = [[1, 3], [2, 5], [3, 7], [4, 9], [5, 11]]) == True\n assert candidate(coordinates = [[-2, 3], [-1, 4], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]]) == True\n assert candidate(coordinates = [[10000, 10000], [5000, 5000], [0, 0], [-5000, -5000], [-10000, -10000]]) == True\n assert candidate(coordinates = [[-20, -30], [-10, -15], [0, 0], [10, 15], [20, 30]]) == True\n assert candidate(coordinates = [[-5, 5], [-10, 10], [-15, 15], [-20, 20], [-25, 25], [-30, 30]]) == True\n assert candidate(coordinates = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15]]) == True\n assert candidate(coordinates = [[-5, -10], [0, 0], [5, 10], [10, 20], [15, 30]]) == True\n assert candidate(coordinates = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0]]) == True\n assert candidate(coordinates = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35]]) == True\n assert candidate(coordinates = [[-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3]]) == True\n assert candidate(coordinates = [[-2, 1], [-1, 3], [0, 5], [1, 7], [2, 9], [3, 11]]) == True\n assert candidate(coordinates = [[-4, -2], [-2, 0], [0, 2], [2, 4], [4, 6]]) == True\n assert candidate(coordinates = [[-100, 100], [-50, 150], [0, 200], [50, 250], [100, 300]]) == True\n assert candidate(coordinates = [[-2, 2], [0, 0], [2, -2], [4, -4], [6, -6]]) == True\n assert candidate(coordinates = [[-1, -2], [1, 0], [3, 2], [5, 4], [7, 6], [9, 8]]) == True\n assert candidate(coordinates = [[-10, 15], [-5, 10], [0, 5], [5, 0], [10, -5]]) == True\n assert candidate(coordinates = [[5, 0], [5, 1], [5, 2], [5, 3], [5, 4]]) == True\n assert candidate(coordinates = [[0, -10], [0, -5], [0, 0], [0, 5], [0, 10], [0, 15]]) == True\n assert candidate(coordinates = [[100, 200], [200, 400], [300, 600], [400, 800], [500, 1000]]) == True\n assert candidate(coordinates = [[0, 1], [1, 3], [2, 5], [3, 7], [4, 9]]) == True\n assert candidate(coordinates = [[-3, 7], [-2, 5], [-1, 3], [0, 1], [1, -1], [2, -3]]) == True\n assert candidate(coordinates = [[-1, -2], [1, 0], [3, 2], [5, 4], [7, 6], [9, 8], [11, 10]]) == True\n assert candidate(coordinates = [[-500, 500], [-250, 750], [0, 1000], [250, 1250], [500, 1500]]) == True\n assert candidate(coordinates = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1]]) == True\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == True\n assert candidate(coordinates = [[-10, 0], [-5, 0], [0, 0], [5, 0], [10, 0], [15, 0]]) == True\n assert candidate(coordinates = [[-2, -1], [0, 0], [2, 1], [4, 2], [6, 3], [8, 4]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == True\n assert candidate(coordinates = [[-2, -3], [-1, -1], [0, 1], [1, 3], [2, 5], [3, 7]]) == True\n assert candidate(coordinates = [[-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3]]) == True\n assert candidate(coordinates = [[-100, 200], [-200, 400], [-300, 600], [-400, 800], [-500, 1000]]) == True\n assert candidate(coordinates = [[-5, -10], [0, 0], [5, 10], [10, 20], [15, 30]]) == True\n assert candidate(coordinates = [[-5, -10], [-4, -8], [-3, -6], [-2, -4], [-1, -2], [0, 0]]) == True\n assert candidate(coordinates = [[-5, -5], [0, 0], [5, 5], [10, 10], [15, 15], [20, 20]]) == True\n assert candidate(coordinates = [[-100, 100], [-50, 50], [0, 0], [50, -50], [100, -100]]) == True\n assert candidate(coordinates = [[-5, 5], [-4, 4], [-3, 3], [-2, 2], [-1, 1], [0, 0]]) == True\n assert candidate(coordinates = [[-100, -100], [-50, -50], [0, 0], [50, 50], [100, 100]]) == True\n assert candidate(coordinates = [[-5, 5], [0, 10], [5, 15], [10, 20], [15, 25], [20, 30], [25, 35]]) == True\n assert candidate(coordinates = [[100, -200], [200, -400], [300, -600], [400, -800], [500, -1000]]) == True\n assert candidate(coordinates = [[1, 3], [2, 5], [3, 7], [4, 9], [5, 11], [6, 13], [7, 15], [8, 17], [9, 19], [10, 21]]) == True\n assert candidate(coordinates = [[-1, -2], [-2, -4], [-3, -6], [-4, -8], [-5, -10]]) == True\n assert candidate(coordinates = [[100, 100], [200, 200], [300, 300], [400, 401], [500, 500]]) == False\n assert candidate(coordinates = [[-100, 100], [100, -100], [0, 0]]) == True\n assert candidate(coordinates = [[2, 3], [4, 6], [6, 9], [8, 12], [10, 15]]) == True\n assert candidate(coordinates = [[-3, 3], [-6, 6], [-9, 9], [-12, 12], [-15, 15]]) == True\n assert candidate(coordinates = [[-1, 0], [0, 1], [1, 0], [0, -1], [-1, 0]]) == False\n assert candidate(coordinates = [[-10, -20], [0, 0], [10, 20], [20, 40], [30, 60]]) == True\n assert candidate(coordinates = [[1, 1], [3, 5], [5, 9], [7, 13], [9, 17]]) == True\n assert candidate(coordinates = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10]]) == True\n assert candidate(coordinates = [[-1, -5], [0, -2], [1, 1], [2, 4], [3, 7], [4, 10]]) == True\n assert candidate(coordinates = [[0, 1000], [1000, 1000], [2000, 1000], [3000, 1000], [4000, 1000]]) == True\n assert candidate(coordinates = [[-2, -3], [-1, -1], [0, 1], [1, 3], [2, 5]]) == True\n assert candidate(coordinates = [[1, 2], [2, 4], [4, 8], [8, 16], [16, 32], [32, 64]]) == True\n assert candidate(coordinates = [[-100, -200], [-200, -400], [-300, -600], [-400, -800], [-500, -1000]]) == True\n assert candidate(coordinates = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14]]) == True\n assert candidate(coordinates = [[1, 2], [4, 6], [7, 10], [10, 14], [13, 18], [16, 22], [19, 26]]) == True\n assert candidate(coordinates = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == True\n assert candidate(coordinates = [[-3, -6], [1, -2], [5, 2], [7, 3]]) == False\n assert candidate(coordinates = [[-100, 0], [0, 0], [100, 0], [200, 0], [300, 0]]) == True\n assert candidate(coordinates = [[-1000, 2000], [0, 0], [1000, -2000]]) == True\n assert candidate(coordinates = [[-5, -10], [0, 0], [5, 10], [10, 20], [15, 30], [20, 40]]) == True\n assert candidate(coordinates = [[-10, 0], [0, 5], [10, 10], [20, 15], [30, 20], [40, 25], [50, 30], [60, 35]]) == True\n assert candidate(coordinates = [[-1, 1], [0, 0], [1, -1], [2, -2], [3, -3]]) == True\n assert candidate(coordinates = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == True\n assert candidate(coordinates = [[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10]]) == True\n assert candidate(coordinates = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]]) == True\n assert candidate(coordinates = [[-10, -10], [-5, -5], [0, 0], [5, 5], [10, 10]]) == True\n assert candidate(coordinates = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]) == True\n assert candidate(coordinates = [[0, 1], [1, 2], [2, 3], [3, 5], [4, 6], [5, 8]]) == False\n assert candidate(coordinates = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 15]]) == False\n assert candidate(coordinates = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80]]) == True\n assert candidate(coordinates = [[-1, -1], [1, 1], [3, 3], [5, 5], [7, 7], [9, 9]]) == True\n assert candidate(coordinates = [[-1000, 0], [-500, 0], [0, 0], [500, 0], [1000, 0]]) == True\n assert candidate(coordinates = [[-10000, 10000], [-5000, 10000], [0, 10000], [5000, 10000], [10000, 10000]]) == True\n assert candidate(coordinates = [[5, 3], [10, 6], [15, 9], [20, 12], [25, 15]]) == True\n assert candidate(coordinates = [[1, 1], [2, 2], [3, 3], [4, 3], [5, 5]]) == False\n assert candidate(coordinates = [[-2, 4], [-1, 2], [0, 0], [1, -2], [2, -4]]) == True\n assert candidate(coordinates = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == True\n", "comparison": "exact"}, "public_tests": ["[[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]]", "[[1,1],[2,2],[3,4],[4,5],[5,6],[7,7]]"], "hints": ["If there're only 2 points, return true.", "Check if all other points lie on the line defined by the first 2 points.", "Use cross product to check collinearity."], "metadata": {"canonical_parameter_names": ["coordinates"], "leetcode_dataset_entry_point": "Solution().checkStraightLine", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:03+00:00", "tests_total": 125, "tests_dropped": 2, "flags": ["has_images"], "topic_tags": ["array", "math", "geometry"]}, "language": "java", "interface": {"raw_signature": "public boolean checkStraightLine(int[][] coordinates) {", "container": "Solution", "callable": "checkStraightLine", "parameters": [{"name": "coordinates", "type": "int[][]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1233, "task_id": "remove-sub-folders-from-the-filesystem", "difficulty": "Medium", "problem_description": "Given a list of folders folder, return the folders after removing all sub-folders in those folders. You may return the answer in any order.\n\nIf a folder[i] is located within another folder[j], it is called a sub-folder of it. A sub-folder of folder[j] must start with folder[j], followed by a \"/\". For example, \"/a/b\" is a sub-folder of \"/a\", but \"/b\" is not a sub-folder of \"/a/b/c\".\n\nThe format of a path is one or more concatenated strings of the form: '/' followed by one or more lowercase English letters.\n\n- For example, \"/leetcode\" and \"/leetcode/problems\" are valid paths while an empty string and \"/\" are not.\n\nExample 1:\n\nInput: folder = [\"/a\",\"/a/b\",\"/c/d\",\"/c/d/e\",\"/c/f\"]\nOutput: [\"/a\",\"/c/d\",\"/c/f\"]\nExplanation: Folders \"/a/b\" is a subfolder of \"/a\" and \"/c/d/e\" is inside of folder \"/c/d\" in our filesystem.\n\nExample 2:\n\nInput: folder = [\"/a\",\"/a/b/c\",\"/a/b/d\"]\nOutput: [\"/a\"]\nExplanation: Folders \"/a/b/c\" and \"/a/b/d\" will be removed because they are subfolders of \"/a\".\n\nExample 3:\n\nInput: folder = [\"/a/b/c\",\"/a/b/ca\",\"/a/b/d\"]\nOutput: [\"/a/b/c\",\"/a/b/ca\",\"/a/b/d\"]\n\nConstraints:\n\n- 1 <= folder.length <= 4 * 10^4\n- 2 <= folder[i].length <= 100\n- folder[i] contains only lowercase letters and '/'.\n- folder[i] always starts with the character '/'.\n- Each folder name is unique.\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(folder=['/a', '/a/b', '/c/d', '/c/d/e', '/c/f']), ['/a', '/c/d', '/c/f'])\n assert answers_match(candidate(folder=['/a', '/a/b/c', '/a/b/d']), ['/a'])\n assert answers_match(candidate(folder=['/m', '/m/n/o', '/m/n', '/p/q', '/p/q/r/s', '/p/q/t']), ['/m', '/p/q'])\n assert answers_match(candidate(folder=['/one', '/one/two', '/three', '/three/four', '/three/four/five']), ['/one', '/three'])\n assert answers_match(candidate(folder=['/a/b/c', '/a/b/ca', '/a/b/d']), ['/a/b/c', '/a/b/ca', '/a/b/d'])\n assert answers_match(candidate(folder=['/x', '/x/y/z', '/x/y', '/z/a', '/z/a/b']), ['/x', '/z/a'])\n assert answers_match(candidate(folder=['/x', '/x/y', '/x/y/z', '/x/y/za', '/w']), ['/w', '/x'])\n assert answers_match(candidate(folder=['/a', '/a/b/c', '/a/b/d']), ['/a'])\n assert answers_match(candidate(folder=['/x', '/x/y/z', '/x/y', '/z', '/z/w']), ['/x', '/z'])\n assert answers_match(candidate(folder=['/x', '/x/y/z', '/x/y', '/w']), ['/w', '/x'])\n assert answers_match(candidate(folder=['/a/b/c', '/a/b/ca', '/a/b/d']), ['/a/b/c', '/a/b/ca', '/a/b/d'])\n assert answers_match(candidate(folder=['/one/two/three', '/one/two/three/four', '/one', '/two/three']), ['/one', '/two/three'])\n assert answers_match(candidate(folder=['/m/n', '/m/no', '/m/no/p', '/m/no/qr', '/m/ns']), ['/m/n', '/m/no', '/m/ns'])\n assert answers_match(candidate(folder=['/a', '/a/b', '/c/d', '/c/d/e', '/c/f']), ['/a', '/c/d', '/c/f'])\n assert answers_match(candidate(folder=['/x/y/z', '/x/y/z/alpha', '/x/y/z/beta', '/x/y/z/gamma/delta', '/x/y/z/gamma/epsilon']), ['/x/y/z'])\n assert answers_match(candidate(folder=['/x/y/z', '/x/y', '/x/y/z/a', '/x/y/z/b/c', '/w/x/y/z', '/w/x/y']), ['/w/x/y', '/x/y'])\n assert answers_match(candidate(folder=['/root/user/documents', '/root/user/documents/reports', '/root/user/images', '/root/user/images/profile']), ['/root/user/documents', '/root/user/images'])\n assert answers_match(candidate(folder=['/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n', '/a/b/c/d/e/f/g/h/i/j/k/l/m', '/a/b/c/d/e/f/g/h/i/j/k/l', '/a/b/c/d/e/f/g/h/i/j/k', '/a/b/c/d/e/f/g/h/i/j', '/a/b/c/d/e/f/g/h/i', '/a/b/c/d/e/f/g/h', '/a/b/c/d/e/f/g', '/a/b/c/d/e/f', '/a/b/c/d/e', '/a/b/c/d', '/a/b/c', '/a/b', '/a']), ['/a'])\n assert answers_match(candidate(folder=['/library/books', '/library/books/fiction', '/library/books/fiction/scifi', '/library/books/fiction/scifi/fantasy', '/library/books/fiction/romance', '/library/books/nonfiction', '/library/books/nonfiction/biography', '/library/books/nonfiction/history']), ['/library/books'])\n assert answers_match(candidate(folder=['/m/n/o/p/q/r/s/t/u/v', '/m/n/o/p/q/r/s/t/u/v/w/x/y/z', '/m/n/o/p/q/r/s/t/u', '/m/n/o/p', '/m/n/o/p/q']), ['/m/n/o/p'])\n assert answers_match(candidate(folder=['/books/science', '/books/science/physics', '/books/science/chemistry', '/books/science/biology', '/books/history', '/books/history/europe', '/books/history/asia']), ['/books/history', '/books/science'])\n assert answers_match(candidate(folder=['/alpha/beta/gamma/delta/epsilon/phi/chi', '/alpha/beta/gamma/delta/epsilon/phi/chi/psi', '/alpha/beta/gamma/delta/epsilon/phi/chi/psi/omega', '/alpha/beta/gamma/delta/epsilon/phi/theta']), ['/alpha/beta/gamma/delta/epsilon/phi/chi', '/alpha/beta/gamma/delta/epsilon/phi/theta'])\n assert answers_match(candidate(folder=['/root/user/documents', '/root/user/documents/projects', '/root/user/downloads', '/root/user/downloads/archive', '/root/user/downloads/archive/old']), ['/root/user/documents', '/root/user/downloads'])\n assert answers_match(candidate(folder=['/deep/nested/folder/structure/here', '/deep/nested/folder/structure/here/is', '/deep/nested/folder/structure/here/is/a', '/deep/nested/folder/structure/here/is/a/test', '/deep/nested/folder/structure/here/is/a/test/file']), ['/deep/nested/folder/structure/here'])\n assert answers_match(candidate(folder=['/x/y/z', '/x/y/z/w', '/x/y/z/w/x', '/x/y/z/w/x/y', '/x/y/z/w/x/y/z', '/x/y/z/w/x/y/z/a']), ['/x/y/z'])\n assert answers_match(candidate(folder=['/abc/def/ghi/jkl', '/abc/def/ghi/jkl/mno', '/abc/def/ghi/jkl/mno/pqr', '/abc/def/ghi/jkl/mno/pqr/stu', '/abc/def/ghi/jkl/mno/pqr/vwx', '/abc/def/ghi/jkl/mno/pqr/vwx/yz']), ['/abc/def/ghi/jkl'])\n assert answers_match(candidate(folder=['/x/y/z', '/x/y/z/w', '/x/y/zx', '/x/y/z/xy']), ['/x/y/z', '/x/y/zx'])\n assert answers_match(candidate(folder=['/root/project/src/main/java/com/example', '/root/project/src', '/root/project/tests/unit', '/root/project']), ['/root/project'])\n assert answers_match(candidate(folder=['/alpha/beta/gamma/delta', '/alpha/beta/gamma/delta/epsilon', '/alpha/beta/gamma/delta/epsilon/zeta', '/alpha/beta/gamma/delta/eta', '/alpha/beta/gamma/delta/eta/theta', '/alpha/beta/gamma/delta/eta/theta/iota']), ['/alpha/beta/gamma/delta'])\n assert answers_match(candidate(folder=['/alpha/bravo/charlie/delta', '/alpha/bravo/charlie/delta/echo', '/alpha/bravo/charlie/delta/echo/foxtrot', '/alpha/bravo/charlie/delta/echo/foxtrot/golf']), ['/alpha/bravo/charlie/delta'])\n assert answers_match(candidate(folder=['/root/a/b/c/d/e/f/g/h/i', '/root/a/b/c/d/e/f/g', '/root/a/b/c/d/e', '/root/a/b/c']), ['/root/a/b/c'])\n assert answers_match(candidate(folder=['/one/two/three/four/five/six/seven', '/one/two/three/four/five/six/seven/eight', '/one/two/three/four/five/six/seven/eight/nine', '/one/two/three/four/five/six/seven/eight/ten']), ['/one/two/three/four/five/six/seven'])\n assert answers_match(candidate(folder=['/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w']), ['/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w'])\n assert answers_match(candidate(folder=['/a/b/c/d/e', '/a/b/c/d', '/a/b/c/d/f', '/a/b/c/d/f/g', '/a/b/c/d/f/h']), ['/a/b/c/d'])\n assert answers_match(candidate(folder=['/base/a', '/base/a/b', '/base/a/b/c', '/base/a/b/d', '/base/a/b/e/f', '/base/a/b/e/g', '/base/a/b/h/i/j/k', '/base/a/b/h/i/l', '/base/a/b/h/i/m/n/o/p']), ['/base/a'])\n assert answers_match(candidate(folder=['/zoo/animals/mammals/carnivores/lions', '/zoo/animals/mammals/carnivores/tigers', '/zoo/animals/mammals/herbivores/elephants', '/zoo/animals/mammals/herbivores/giraffes', '/zoo/animals/birds/flying/eagles', '/zoo/animals/birds/flying/penguins', '/zoo/animals/birds/nonflying/ostriches', '/zoo/animals/birds/nonflying/emus']), ['/zoo/animals/birds/flying/eagles', '/zoo/animals/birds/flying/penguins', '/zoo/animals/birds/nonflying/emus', '/zoo/animals/birds/nonflying/ostriches', '/zoo/animals/mammals/carnivores/lions', '/zoo/animals/mammals/carnivores/tigers', '/zoo/animals/mammals/herbivores/elephants', '/zoo/animals/mammals/herbivores/giraffes'])\n assert answers_match(candidate(folder=['/root/a', '/root/a/b', '/root/a/b/c', '/root/a/b/d', '/root/a/b/e/f', '/root/a/b/e/g', '/root/a/b/e', '/root/a/b/e/g/h']), ['/root/a'])\n assert answers_match(candidate(folder=['/a/b/c/d', '/a/b/c/d/e', '/a/b/c/d/f', '/a/b/c/d/g', '/a/b/c/d/h/i']), ['/a/b/c/d'])\n assert answers_match(candidate(folder=['/projects/alpha/beta/gamma/delta/epsilon/zeta', '/projects/alpha/beta/gamma/delta/epsilon/eta', '/projects/alpha/beta/gamma/delta', '/projects/alpha/beta/gamma', '/projects/alpha/beta']), ['/projects/alpha/beta'])\n assert answers_match(candidate(folder=['/x/y/z', '/x/y', '/x/y/z/w', '/x/y/v', '/x/y/z/v', '/x/y/v/w', '/x/u/v']), ['/x/u/v', '/x/y'])\n assert answers_match(candidate(folder=['/x/y/z', '/x/y/za', '/x/ya', '/x/yb', '/x/yc/zc', '/x/yc/zb']), ['/x/y/z', '/x/y/za', '/x/ya', '/x/yb', '/x/yc/zb', '/x/yc/zc'])\n assert answers_match(candidate(folder=['/a/b/c/d', '/a/b/c', '/a/b', '/a', '/a/b/c/d/e', '/a/b/c/f', '/a/g', '/a/g/h', '/a/g/i/j', '/a/g/i/j/k']), ['/a'])\n assert answers_match(candidate(folder=['/projects/webapp/client', '/projects/webapp/client/src', '/projects/webapp/client/src/components', '/projects/webapp/server', '/projects/webapp/server/routes', '/projects/webapp/server/models']), ['/projects/webapp/client', '/projects/webapp/server'])\n assert answers_match(candidate(folder=['/project/src/main/java/com/example', '/project/src/main/java/com/example/model', '/project/src/main/java/com/example/service', '/project/src/test/java/com/example/service', '/project/src/test/resources', '/project/src/main/resources']), ['/project/src/main/java/com/example', '/project/src/main/resources', '/project/src/test/java/com/example/service', '/project/src/test/resources'])\n assert answers_match(candidate(folder=['/x/y/z', '/x/y/za', '/x/y', '/x/y/z/zzz', '/x/y/z/zza']), ['/x/y'])\n assert answers_match(candidate(folder=['/code/base', '/code/base/core', '/code/base/core/utils', '/code/base/core/utils/a', '/code/base/core/utils/b', '/code/base/core/models', '/code/base/core/models/user', '/code/base/core/models/group']), ['/code/base'])\n assert answers_match(candidate(folder=['/a/b', '/a/b/c', '/a/b/c/d', '/a/b/c/d/e', '/a/b/c/d/e/f', '/a/b/c/d/e/f/g', '/a/b/c/d/e/f/g/h', '/a/b/c/d/e/f/g/h/i', '/a/b/c/d/e/f/g/h/i/j', '/a/b/c/d/e/f/g/h/i/j/k', '/a/b/c/d/e/f/g/h/i/j/k/l', '/a/b/c/d/e/f/g/h/i/j/k/l/m', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p', '/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q']), ['/a/b'])\n assert answers_match(candidate(folder=['/m/n/o/p/q/r', '/m/n/o/p/q/r/s', '/m/n/o/p/q/r/s/t', '/m/n/o/p/q/r/u', '/m/n/o/p/v', '/m/n/o/p/v/w', '/m/n/o/p/v/w/x']), ['/m/n/o/p/q/r', '/m/n/o/p/v'])\n assert answers_match(candidate(folder=['/mnt/external/storage', '/mnt/external/storage/backup', '/mnt/external/storage/photos', '/mnt/external/storage/photos/vacation', '/mnt/external/storage/photos/wedding', '/mnt/external/storage/videos', '/mnt/external/storage/videos/home', '/mnt/external/storage/videos/travel']), ['/mnt/external/storage'])\n assert answers_match(candidate(folder=['/user/home', '/user/home/settings', '/user/home/settings/preferences', '/user/home/settings/notifications', '/user/home/documents', '/user/home/documents/work', '/user/home/documents/personal']), ['/user/home'])\n assert answers_match(candidate(folder=['/p/q/r', '/p/q/r/s', '/p/q/r/s/t', '/p/q/r/s/u', '/p/q/v', '/p/q/v/w', '/p/q/v/w/x', '/p/q/v/w/y']), ['/p/q/r', '/p/q/v'])\n assert answers_match(candidate(folder=['/project/src', '/project/src/components', '/project/src/components/button', '/project/src/components/input', '/project/src/utils', '/project/src/utils/helpers', '/project/src/utils/api', '/project/src/assets', '/project/src/assets/images', '/project/src/assets/fonts', '/project/src/assets/icons']), ['/project/src'])\n assert answers_match(candidate(folder=['/a/b/c/d/e/f', '/a/b/c/d', '/a/b/c', '/a/b', '/a', '/z/y/x', '/z/y', '/z']), ['/a', '/z'])\n", "comparison": "unordered"}, "public_tests": ["[\"/a\",\"/a/b\",\"/c/d\",\"/c/d/e\",\"/c/f\"]", "[\"/a\",\"/a/b/c\",\"/a/b/d\"]", "[\"/a/b/c\",\"/a/b/ca\",\"/a/b/d\"]"], "hints": ["Sort the folders lexicographically.", "Insert the current element in an array and then loop until we get rid of all of their subfolders, repeat this until no element is left."], "metadata": {"canonical_parameter_names": ["folder"], "leetcode_dataset_entry_point": "Solution().removeSubfolders", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:06+00:00", "tests_total": 97, "tests_dropped": 44, "flags": ["any_order"], "topic_tags": ["array", "string", "depth-first-search", "trie"]}, "language": "java", "interface": {"raw_signature": "public List removeSubfolders(String[] folder) {", "container": "Solution", "callable": "removeSubfolders", "parameters": [{"name": "folder", "type": "String[]"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1234, "task_id": "replace-the-substring-for-balanced-string", "difficulty": "Medium", "problem_description": "You are given a string s of length n containing only four kinds of characters: 'Q', 'W', 'E', and 'R'.\n\nA string is said to be balanced if each of its characters appears n / 4 times where n is the length of the string.\n\nReturn the minimum length of the substring that can be replaced with any other string of the same length to make s balanced. If s is already balanced, return 0.\n\nExample 1:\n\nInput: s = \"QWER\"\nOutput: 0\nExplanation: s is already balanced.\n\nExample 2:\n\nInput: s = \"QQWE\"\nOutput: 1\nExplanation: We need to replace a 'Q' to 'R', so that \"RQWE\" (or \"QRWE\") is balanced.\n\nExample 3:\n\nInput: s = \"QQQW\"\nOutput: 2\nExplanation: We can replace the first \"QQ\" to \"ER\".\n\nConstraints:\n\n- n == s.length\n- 4 <= n <= 10^5\n- n is a multiple of 4.\n- s contains only 'Q', 'W', 'E', and 'R'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"QQQQQQQQWWWWEEEEEEEERRRRRRRR\") == 14\n assert candidate(s = \"QQQQWWER\") == 2\n assert candidate(s = \"QQQQWWWWEEEERRRR\") == 0\n assert candidate(s = \"QQWWRRER\") == 1\n assert candidate(s = \"QQQQWWWEERRR\") == 1\n assert candidate(s = \"QQQQQQQQWWWWWWWWEEEEEEEERRRRRRRR\") == 0\n assert candidate(s = \"QQQWEEERRRQQQWEEERRR\") == 5\n assert candidate(s = \"QWERQWERQWERQWER\") == 0\n assert candidate(s = \"QQQWEEEERRRQ\") == 3\n assert candidate(s = \"QQWE\") == 1\n assert candidate(s = \"QQQW\") == 2\n assert candidate(s = \"QWER\") == 0\n assert candidate(s = \"QQQQEEEERRRR\") == 6\n assert candidate(s = \"WQWRQQQW\") == 3\n assert candidate(s = \"QQQQWEEEWWRR\") == 1\n assert candidate(s = \"QWQWQWQW\") == 4\n assert candidate(s = \"QQQQEEEEWWWWRRRR\") == 0\n assert candidate(s = \"QQQQWEEEERRR\") == 3\n assert candidate(s = \"QQQQWWEERRRRQQQQ\") == 4\n assert candidate(s = \"QQQWEEEERRRR\") == 2\n assert candidate(s = \"QQQQQQQQWWWWWWWWEEEEEEEEEEEEEEEEEEEEEEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRQQQQQQQQWWWWWWWWEEEEEEEEEEEEEEEEEEEEEEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 42\n assert candidate(s = \"QQWWEERRQQWWEERRQQWWEERR\") == 0\n assert candidate(s = \"QQQQQWEEEEERRRRR\") == 8\n assert candidate(s = \"WWWWWWWWQQQQEEEERRRR\") == 3\n assert candidate(s = \"QWQWQWQWQWQWQWQWQWQWQWQWQWQWQWQW\") == 16\n assert candidate(s = \"EEEEWWRRQQQQEEEEWWRRQQQQ\") == 4\n assert candidate(s = \"QQQQWWWWEEEEEEEEEEEEEEERRRRRRRRRRRRRRRRRRRRR\") == 14\n assert candidate(s = \"EEEEEEEEWWWWWWWWRRRRRRRRQQQQQQQQ\") == 0\n assert candidate(s = \"QWQWQWQWQWQWQWQW\") == 8\n assert candidate(s = \"QQQQQQQQWWWWWWWWWEEEEEEEEEEEEEEEEERRRRRRRRRRRRRR\") == 7\n assert candidate(s = \"QQQQQQQQWWWWWWWWEEEEEEEERRRRRRRRRRRRRRRRRRRR\") == 9\n assert candidate(s = \"QQQWWWWWWWWEEEEEEEEEEEEEEEEERRRRRRRRRRRRRRRR\") == 11\n assert candidate(s = \"WQQQWEWQERWREWER\") == 1\n assert candidate(s = \"QWQWQWQWQQQQQQQQEEEEWWRRQQQQ\") == 10\n assert candidate(s = \"QQQQQQQQWEEEEEEEEEERRRRRRRRR\") == 14\n assert candidate(s = \"QQQQQQWWEEEERRRR\") == 2\n assert candidate(s = \"QQQQQQQQWWWWWWWWEEEEEEEEEEEEEEEEEEEEEEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRQQQQQQQQWWWWWWWWEEEEEEEEEEEEEEEEEEEEEEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRQQQQQQQQWWWWWWWWEEEEEEEEEEEEEEEEEEEEEEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRQQQQQQQQWWWWWWWWEEEEEEEEEEEEEEEEEEEEEEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 102\n assert candidate(s = \"QQQQWWEEREEE\") == 5\n assert candidate(s = \"QQWWEERRQQWWEERR\") == 0\n assert candidate(s = \"QQQQWWWWEEEERRRRQQQQWWWWEEEE\") == 6\n assert candidate(s = \"QQQWEEEERRRRQQQWEEEERRRR\") == 4\n assert candidate(s = \"QQQWEEERRQQQWEEERRQQQWEEERRQQQWEEERRQQQWEEERRQQQWEEERRQQQWEEERRQQQWEEERR\") == 16\n assert candidate(s = \"QQQWEEERRRRQQQWEEERRRRQQQWEEERRRRQQQWEEERRRRQQQWEEERRRRQQQWEEERRRRQQQWEEERRRRQQQWEEERRRR\") == 24\n assert candidate(s = \"QQQQQQQQEEEEEEEEEEEEEEEEEEEERRRRRRRRRRRRRRRR\") == 14\n assert candidate(s = \"WQQQWQQQWQQQWQQQEEEEWWRRQQQQ\") == 11\n assert candidate(s = \"QQQWEEEEWWRRQQQQEEEEWWRR\") == 3\n assert candidate(s = \"QWQWQWQWQWQWQQQQWWRRQQQQ\") == 12\n assert candidate(s = \"QQQQQQWWWWWWEEEEEEEEEERRRRRRRRRRRRRR\") == 6\n assert candidate(s = \"QWQQQQQQQQQWEWEWEWRR\") == 5\n assert candidate(s = \"QQQWWEERQQRRQWRE\") == 2\n assert candidate(s = \"QQQQEEEEWWRR\") == 2\n assert candidate(s = \"QQQQQQQQQQQQQQQQEEEEEEEEEEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 30\n assert candidate(s = \"QQQQQQQQQQQQQQQQEEEEEEEERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 28\n assert candidate(s = \"QQQQWWEERRRRQQQQWWEERRRR\") == 4\n assert candidate(s = \"QQQQWWEERRRRQQQQWWEERRRRQQQQWWEERRRR\") == 6\n assert candidate(s = \"QQQQWEEEEEERRRRR\") == 3\n assert candidate(s = \"QQQQQQQQWWWWWWWWWWWWWWWWWWEEEEEERRRR\") == 9\n assert candidate(s = \"QQQWEEEEEERRRRQQ\") == 4\n assert candidate(s = \"RRRRRRRRQQQQQQQQWWWWWWWWEEEEEEEE\") == 0\n assert candidate(s = \"QQWWEERRRRWWWWRRRRQQQWEEERRRRWWWWRRRRQQQWEEERRRRWWWWRRRR\") == 21\n assert candidate(s = \"QQWWEERRRRWWWWRRRRWWWWRRRRWWWWRRRRQQWWEERRRRWWWWRRRR\") == 19\n assert candidate(s = \"WWWWQQQQEEEERRRRWWWWQQQQEEEERRRR\") == 0\n assert candidate(s = \"QQQQQQQQWWEERRRR\") == 4\n", "comparison": "exact"}, "public_tests": ["\"QWER\"", "\"QQWE\"", "\"QQQW\""], "hints": ["Use 2-pointers algorithm to make sure all amount of characters outside the 2 pointers are smaller or equal to n/4.", "That means you need to count the amount of each letter and make sure the amount is enough."], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().balancedString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:08+00:00", "tests_total": 158, "tests_dropped": 95, "flags": [], "topic_tags": ["string", "sliding-window"]}, "language": "java", "interface": {"raw_signature": "public int balancedString(String s) {", "container": "Solution", "callable": "balancedString", "parameters": [{"name": "s", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1235, "task_id": "maximum-profit-in-job-scheduling", "difficulty": "Hard", "problem_description": "We have n jobs, where every job is scheduled to be done from startTime[i] to endTime[i], obtaining a profit of profit[i].\n\nYou're given the startTime, endTime and profit arrays, return the maximum profit you can take such that there are no two jobs in the subset with overlapping time range.\n\nIf you choose a job that ends at time X you will be able to start another job that starts at time X.\n\nExample 1:\n\nInput: startTime = [1,2,3,3], endTime = [3,4,5,6], profit = [50,10,40,70]\nOutput: 120\nExplanation: The subset chosen is the first and fourth job.\nTime range [1-3]+[3-6] , we get profit of 120 = 50 + 70.\n\nExample 2:\n\nInput: startTime = [1,2,3,4,6], endTime = [3,5,10,6,9], profit = [20,20,100,70,60]\nOutput: 150\nExplanation: The subset chosen is the first, fourth and fifth job.\nProfit obtained 150 = 20 + 70 + 60.\n\nExample 3:\n\nInput: startTime = [1,1,1], endTime = [2,3,4], profit = [5,6,4]\nOutput: 6\n\nConstraints:\n\n- 1 <= startTime.length == endTime.length == profit.length <= 5 * 10^4\n- 1 <= startTime[i] < endTime[i] <= 10^9\n- 1 <= profit[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(startTime = [1, 10, 4, 3, 8, 9],endTime = [2, 11, 5, 7, 9, 10],profit = [3, 1, 5, 6, 4, 3]) == 17\n assert candidate(startTime = [1, 3, 5, 6, 7],endTime = [3, 5, 9, 8, 9],profit = [50, 20, 60, 40, 30]) == 130\n assert candidate(startTime = [1, 10, 100, 1000],endTime = [2, 20, 200, 2000],profit = [5, 50, 500, 5000]) == 5555\n assert candidate(startTime = [1, 3, 6, 8],endTime = [2, 5, 10, 12],profit = [50, 20, 100, 80]) == 170\n assert candidate(startTime = [3, 1, 1, 2],endTime = [4, 2, 4, 3],profit = [50, 10, 40, 70]) == 130\n assert candidate(startTime = [3, 5, 10],endTime = [15, 18, 19],profit = [20, 20, 100]) == 100\n assert candidate(startTime = [1],endTime = [2],profit = [5]) == 5\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(startTime = [1, 3, 6, 8, 12, 14],endTime = [4, 5, 10, 11, 14, 15],profit = [5, 6, 8, 3, 10, 4]) == 28\n assert candidate(startTime = [1, 2, 3, 4, 5, 6],endTime = [2, 3, 4, 5, 6, 7],profit = [1, 2, 3, 4, 5, 6]) == 21\n assert candidate(startTime = [1, 1, 1],endTime = [2, 3, 4],profit = [5, 6, 4]) == 6\n assert candidate(startTime = [1, 2, 3, 3],endTime = [3, 4, 5, 6],profit = [50, 10, 40, 70]) == 120\n assert candidate(startTime = [1, 2, 3, 4, 6],endTime = [3, 5, 10, 6, 9],profit = [20, 20, 100, 70, 60]) == 150\n assert candidate(startTime = [5, 8, 4, 1, 1],endTime = [6, 10, 7, 8, 2],profit = [100, 500, 100, 200, 300]) == 900\n assert candidate(startTime = [1, 3, 6, 8],endTime = [5, 7, 10, 12],profit = [50, 20, 100, 200]) == 250\n assert candidate(startTime = [2, 5, 8, 11],endTime = [5, 7, 10, 14],profit = [20, 30, 40, 50]) == 140\n assert candidate(startTime = [5, 10, 15, 20, 25],endTime = [10, 15, 20, 25, 30],profit = [100, 150, 200, 250, 300]) == 1000\n assert candidate(startTime = [100, 200, 300],endTime = [200, 300, 400],profit = [1000, 2000, 3000]) == 6000\n assert candidate(startTime = [1, 2, 4, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37],endTime = [5, 6, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26, 29, 30, 33, 34, 37, 38, 41, 42],profit = [100, 200, 150, 300, 100, 500, 400, 300, 600, 700, 800, 600, 400, 300, 200, 100, 900, 800, 700, 600]) == 3400\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1000\n assert candidate(startTime = [1, 1, 1, 1, 1, 1],endTime = [2, 3, 4, 5, 6, 7],profit = [100, 200, 300, 400, 500, 600]) == 600\n assert candidate(startTime = [1, 2, 3, 5, 6, 8, 10, 12, 14, 16],endTime = [5, 4, 6, 9, 8, 11, 13, 15, 17, 19],profit = [5, 3, 7, 9, 8, 6, 4, 2, 1, 10]) == 33\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],endTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],profit = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == 325\n assert candidate(startTime = [1, 1, 2, 2, 3, 4, 5, 5, 6, 7],endTime = [3, 4, 4, 5, 6, 7, 7, 8, 9, 10],profit = [50, 40, 30, 20, 60, 10, 20, 100, 5, 45]) == 155\n assert candidate(startTime = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],endTime = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 2100\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],endTime = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],profit = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(startTime = [1, 5, 8, 11, 13, 16, 19, 22, 25, 28],endTime = [4, 9, 12, 15, 17, 20, 23, 26, 29, 32],profit = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 370\n assert candidate(startTime = [3, 7, 10, 12, 13, 14, 15, 16, 18, 20],endTime = [5, 8, 13, 14, 15, 17, 20, 21, 22, 23],profit = [5, 8, 13, 14, 15, 17, 20, 21, 22, 23]) == 84\n assert candidate(startTime = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140],endTime = [5, 14, 24, 34, 44, 54, 64, 74, 84, 94, 104, 114, 124, 134, 144],profit = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 1800\n assert candidate(startTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],endTime = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],profit = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 1000\n assert candidate(startTime = [1, 2, 3, 5, 8, 11, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50],endTime = [4, 6, 9, 13, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == 6900\n assert candidate(startTime = [1, 5, 10, 15, 20, 25, 30],endTime = [4, 9, 14, 19, 24, 29, 34],profit = [100, 200, 300, 400, 500, 600, 700]) == 2800\n assert candidate(startTime = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],endTime = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 22],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 360\n assert candidate(startTime = [1, 3, 6, 8, 12, 15, 18, 20, 25, 30],endTime = [5, 7, 10, 14, 16, 19, 22, 24, 30, 35],profit = [50, 20, 70, 10, 120, 30, 50, 25, 80, 60]) == 430\n assert candidate(startTime = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4],endTime = [2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7, 5, 6, 7, 8],profit = [10, 10, 10, 10, 15, 15, 15, 15, 20, 20, 20, 20, 25, 25, 25, 25]) == 70\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],endTime = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 3000\n assert candidate(startTime = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 11, 11, 12, 13, 14, 15, 16],endTime = [2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, 20, 19, 21, 22, 23, 24],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 42\n assert candidate(startTime = [3, 5, 8, 10, 11, 12, 15, 18, 20, 22],endTime = [4, 9, 11, 13, 14, 17, 19, 23, 24, 25],profit = [20, 30, 5, 10, 50, 40, 70, 60, 10, 20]) == 190\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],endTime = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],profit = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 720\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],endTime = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],profit = [50, 40, 30, 20, 10, 50, 40, 30, 20, 10, 50, 40, 30, 20, 10, 50, 40, 30, 20, 10]) == 600\n assert candidate(startTime = [1, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41],endTime = [6, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48],profit = [30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220]) == 730\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],endTime = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 1200\n assert candidate(startTime = [1, 3, 6, 8, 10, 13, 16, 18, 20, 23],endTime = [4, 7, 10, 12, 14, 17, 20, 22, 24, 27],profit = [500, 400, 300, 200, 100, 50, 75, 125, 175, 225]) == 1250\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],endTime = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 260\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],endTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],profit = [20, 15, 10, 5, 40, 35, 30, 25, 20, 15, 10, 5, 40, 35, 30]) == 335\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],endTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 1360\n assert candidate(startTime = [1, 2, 5, 6, 8, 12, 15, 18, 20, 25],endTime = [5, 5, 10, 10, 13, 17, 20, 22, 28, 30],profit = [50, 20, 70, 10, 30, 60, 5, 40, 90, 25]) == 270\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],endTime = [5, 4, 8, 10, 9, 11, 13, 14, 16, 17, 18, 19, 20, 21, 22],profit = [100, 200, 150, 300, 250, 200, 400, 350, 300, 250, 200, 150, 100, 50, 100]) == 750\n assert candidate(startTime = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900],endTime = [900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800],profit = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 100\n assert candidate(startTime = [1, 5, 8, 10, 13, 16, 18, 20, 22, 25, 27, 29],endTime = [4, 9, 11, 12, 15, 17, 19, 21, 24, 26, 28, 30],profit = [100, 150, 100, 50, 200, 100, 150, 50, 100, 200, 50, 150]) == 1300\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],endTime = [2, 8, 6, 10, 12, 14, 18, 20, 22, 24],profit = [10, 30, 20, 40, 50, 70, 60, 80, 90, 100]) == 250\n assert candidate(startTime = [1, 3, 4, 5, 6, 8, 9],endTime = [2, 5, 7, 7, 9, 10, 11],profit = [10, 20, 40, 10, 30, 50, 20]) == 100\n assert candidate(startTime = [3, 5, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81],endTime = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90],profit = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750]) == 3200\n assert candidate(startTime = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 11, 11, 12, 13, 14, 15, 16],endTime = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22],profit = [20, 25, 20, 30, 35, 40, 35, 45, 50, 55, 50, 60, 65, 70, 65, 75, 80, 85, 90, 95]) == 275\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 100\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],endTime = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],profit = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80]) == 250\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],endTime = [3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15, 17, 17, 19, 19, 21, 21, 23],profit = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 110\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],profit = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 50\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],endTime = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],profit = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000]) == 3850\n assert candidate(startTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],endTime = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 100\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],endTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],profit = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 100\n assert candidate(startTime = [1, 5, 7, 8, 9, 10, 12, 15, 16, 19],endTime = [5, 8, 9, 10, 12, 15, 16, 20, 21, 25],profit = [100, 80, 40, 60, 70, 50, 30, 90, 20, 150]) == 440\n assert candidate(startTime = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],endTime = [2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1010\n assert candidate(startTime = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],endTime = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],profit = [20, 40, 30, 60, 50, 80, 70, 100, 90, 120, 110, 140, 130, 160, 150, 180, 170, 200, 190, 220, 210, 240, 230]) == 750\n assert candidate(startTime = [1, 2, 2, 4, 6, 7, 9, 10],endTime = [3, 3, 5, 8, 7, 10, 12, 15],profit = [50, 20, 30, 40, 60, 70, 80, 90]) == 270\n assert candidate(startTime = [3, 12, 8, 4, 9, 15, 18, 20, 25, 30],endTime = [7, 16, 13, 5, 11, 20, 22, 23, 32, 31],profit = [100, 150, 90, 60, 120, 200, 80, 40, 180, 160]) == 640\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],endTime = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 465\n assert candidate(startTime = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18],endTime = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 300\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],endTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],profit = [500, 300, 700, 100, 400, 800, 200, 600, 900, 1000]) == 5500\n assert candidate(startTime = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],profit = [10, 50, 20, 60, 30, 70, 40, 80, 50, 90, 60]) == 560\n assert candidate(startTime = [1, 2, 3, 5, 8, 13, 21],endTime = [5, 4, 6, 8, 10, 15, 25],profit = [20, 20, 10, 40, 20, 30, 50]) == 160\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1100\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],endTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],profit = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 6050\n assert candidate(startTime = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23],endTime = [6, 8, 10, 12, 14, 16, 18, 20, 22, 24],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 5500\n assert candidate(startTime = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900],endTime = [2, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],profit = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 21000\n assert candidate(startTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],endTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],profit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(startTime = [3, 15, 5, 10, 20, 25],endTime = [10, 20, 10, 15, 25, 30],profit = [50, 70, 30, 60, 100, 40]) == 320\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],profit = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 100\n assert candidate(startTime = [1, 2, 3, 5, 7, 9, 10, 12, 15, 18, 20],endTime = [5, 6, 8, 10, 12, 14, 17, 20, 22, 25, 27],profit = [100, 50, 70, 60, 80, 90, 120, 150, 200, 180, 220]) == 550\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],profit = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500]) == 2750\n assert candidate(startTime = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],endTime = [9, 14, 19, 24, 29, 34, 39, 44, 49, 54],profit = [100, 150, 200, 250, 300, 350, 400, 450, 500, 550]) == 3250\n", "comparison": "exact"}, "public_tests": ["[1,2,3,3]\n[3,4,5,6]\n[50,10,40,70]", "[1,2,3,4,6]\n[3,5,10,6,9]\n[20,20,100,70,60]", "[1,1,1]\n[2,3,4]\n[5,6,4]"], "hints": ["Think on DP.", "Sort the elements by starting time, then define the dp[i] as the maximum profit taking elements from the suffix starting at i.", "Use binarySearch (lower_bound/upper_bound on C++) to get the next index for the DP transition."], "metadata": {"canonical_parameter_names": ["startTime", "endTime", "profit"], "leetcode_dataset_entry_point": "Solution().jobScheduling", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:14:10+00:00", "tests_total": 92, "tests_dropped": 11, "flags": ["has_images"], "topic_tags": ["array", "binary-search", "dynamic-programming", "sorting"]}, "language": "java", "interface": {"raw_signature": "public int jobScheduling(int[] startTime, int[] endTime, int[] profit) {", "container": "Solution", "callable": "jobScheduling", "parameters": [{"name": "startTime", "type": "int[]"}, {"name": "endTime", "type": "int[]"}, {"name": "profit", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} @@ -366,10 +366,10 @@ {"question_id": 1338, "task_id": "reduce-array-size-to-the-half", "difficulty": "Medium", "problem_description": "You are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array.\n\nReturn the minimum size of the set so that at least half of the integers of the array are removed.\n\nExample 1:\n\nInput: arr = [3,3,3,3,5,5,5,2,2,7]\nOutput: 2\nExplanation: Choosing {3,7} will make the new array [5,5,5,2,2] which has size 5 (i.e equal to half of the size of the old array).\nPossible sets of size 2 are {3,5},{3,2},{5,2}.\nChoosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] which has a size greater than half of the size of the old array.\n\nExample 2:\n\nInput: arr = [7,7,7,7,7,7]\nOutput: 1\nExplanation: The only possible set you can choose is {7}. This will make the new array empty.\n\nConstraints:\n\n- 2 <= arr.length <= 10^5\n- arr.length is even.\n- 1 <= arr[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [7, 7, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [10, 10, 20, 20, 20, 30, 30, 30, 30, 30]) == 1\n assert candidate(arr = [3, 3, 3, 3, 5, 5, 5, 2, 2, 7]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 2\n assert candidate(arr = [10, 20, 20, 10, 10, 30, 50, 10, 20, 20]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 4]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 3, 3, 4, 5]) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 3\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == 3\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 25\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 8\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 3\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 9]) == 3\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200]) == 1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 4\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]) == 3\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 3\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3]) == 1\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 1\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 5\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 3\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 5\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 1\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 70, 70, 70, 70, 70, 70, 70]) == 3\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(arr = [99, 99, 98, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, 84, 84, 83, 83, 82, 82, 81, 81, 80, 80, 79, 79, 78, 78, 77, 77, 76, 76, 75, 75, 74, 74, 73, 73, 72, 72, 71, 71, 70, 70, 69, 69, 68, 68, 67, 67, 66, 66, 65, 65, 64, 64, 63, 63, 62, 62, 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 56, 56, 55, 55, 54, 54, 53, 53, 52, 52, 51, 51, 50, 50]) == 25\n assert candidate(arr = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == 3\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(arr = [100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 200, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400]) == 2\n assert candidate(arr = [10, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50, 50]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8]) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 2, 2, 2, 3, 3, 4]) == 1\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 3\n assert candidate(arr = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7]) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4]) == 1\n", "comparison": "exact"}, "public_tests": ["[3,3,3,3,5,5,5,2,2,7]", "[7,7,7,7,7,7]"], "hints": ["Count the frequency of each integer in the array.", "Start with an empty set, add to the set the integer with the maximum frequency.", "Keep Adding the integer with the max frequency until you remove at least half of the integers."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().minSetSize", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:13+00:00", "tests_total": 85, "tests_dropped": 24, "flags": [], "topic_tags": ["array", "hash-table", "greedy", "sorting", "heap-priority-queue"]}, "language": "java", "interface": {"raw_signature": "public int minSetSize(int[] arr) {", "container": "Solution", "callable": "minSetSize", "parameters": [{"name": "arr", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1340, "task_id": "jump-game-v", "difficulty": "Hard", "problem_description": "Given an array of integers arr and an integer d. In one step you can jump from index i to index:\n\n- i + x where: i + x < arr.length and 0 < x <= d.\n- i - x where: i - x >= 0 and 0 < x <= d.\n\nIn addition, you can only jump from index i to index j if arr[i] > arr[j] and arr[i] > arr[k] for all indices k between i and j (More formally min(i, j) < k < max(i, j)).\n\nYou can choose any index of the array and start jumping. Return the maximum number of indices you can visit.\n\nNotice that you can not jump outside of the array at any time.\n\nExample 1:\n\nInput: arr = [6,4,14,6,8,13,9,7,10,6,12], d = 2\nOutput: 4\nExplanation: You can start at index 10. You can jump 10 --> 8 --> 6 --> 7 as shown.\nNote that if you start at index 6 you can only jump to index 7. You cannot jump to index 5 because 13 > 9. You cannot jump to index 4 because index 5 is between index 4 and 6 and 13 > 9.\nSimilarly You cannot jump from index 3 to index 2 or index 1.\n\nExample 2:\n\nInput: arr = [3,3,3,3,3], d = 3\nOutput: 1\nExplanation: You can start at any index. You always cannot jump to any index.\n\nExample 3:\n\nInput: arr = [7,6,5,4,3,2,1], d = 1\nOutput: 7\nExplanation: Start at index 0. You can visit all the indicies.\n\nConstraints:\n\n- 1 <= arr.length <= 1000\n- 1 <= arr[i] <= 10^5\n- 1 <= d <= arr.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 10\n assert candidate(arr = [1, 2, 3, 4, 5],d = 4) == 5\n assert candidate(arr = [1, 2, 3, 4, 5],d = 2) == 5\n assert candidate(arr = [3, 3, 3, 3, 3],d = 3) == 1\n assert candidate(arr = [5, 4, 3, 2, 1],d = 4) == 5\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1],d = 1) == 7\n assert candidate(arr = [6, 4, 14, 6, 8, 13, 9, 7, 10, 6, 12],d = 2) == 4\n assert candidate(arr = [5, 4, 3, 2, 1],d = 1) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],d = 2) == 2\n assert candidate(arr = [1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5],d = 2) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],d = 5) == 1\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 15\n assert candidate(arr = [3, 5, 2, 1, 4, 7, 6, 8, 9, 10],d = 3) == 7\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 4) == 10\n assert candidate(arr = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10, 1],d = 10) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 5) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1],d = 3) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 10) == 20\n assert candidate(arr = [1, 5, 3, 8, 2, 7, 4, 9, 6, 10],d = 5) == 5\n assert candidate(arr = [10, 1, 10, 1, 10, 1, 10],d = 2) == 2\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],d = 6) == 16\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 2) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 5) == 20\n assert candidate(arr = [8, 7, 6, 5, 4, 3, 2, 1, 9, 10, 11, 12, 13, 14, 15, 16, 17],d = 4) == 13\n assert candidate(arr = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 7) == 17\n assert candidate(arr = [6, 1, 5, 3, 2, 7, 4],d = 3) == 4\n assert candidate(arr = [6, 8, 9, 2, 1, 5, 3, 4, 7],d = 2) == 3\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],d = 2) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 2) == 10\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],d = 1) == 2\n assert candidate(arr = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5],d = 2) == 6\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],d = 1) == 9\n assert candidate(arr = [6, 12, 8, 14, 3, 10, 11, 9, 5, 7, 2, 4, 13, 1, 6],d = 4) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 5) == 15\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 20\n assert candidate(arr = [10, 20, 30, 40, 50, 45, 44, 43, 42, 41],d = 3) == 6\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 6) == 15\n assert candidate(arr = [4, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],d = 3) == 4\n assert candidate(arr = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5],d = 3) == 5\n assert candidate(arr = [2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9],d = 3) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 2) == 20\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],d = 2) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 1) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 10) == 10\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],d = 3) == 2\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 50, 40, 30, 20, 10],d = 5) == 6\n assert candidate(arr = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],d = 2) == 6\n assert candidate(arr = [1, 5, 2, 6, 3, 7, 4, 8],d = 2) == 5\n assert candidate(arr = [3, 8, 1, 6, 2, 9, 5, 4, 7],d = 3) == 4\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 4) == 10\n assert candidate(arr = [2, 6, 4, 8, 4, 6, 4, 8, 4, 6, 4, 8, 4, 6, 4, 8, 4, 6, 4, 8],d = 2) == 3\n assert candidate(arr = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1],d = 2) == 3\n assert candidate(arr = [8, 3, 5, 2, 4, 6, 7, 1, 9],d = 3) == 6\n assert candidate(arr = [3, 1, 5, 4, 2, 6, 7, 8, 9, 1],d = 5) == 7\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 5) == 10\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 8, 7, 9],d = 3) == 6\n assert candidate(arr = [10, 20, 15, 25, 30, 5, 40, 35, 50, 45],d = 5) == 6\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],d = 1) == 1\n assert candidate(arr = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10, 100, 10],d = 1) == 2\n assert candidate(arr = [1, 6, 5, 4, 3, 2, 7],d = 3) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 4) == 15\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 2) == 15\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17, 16, 18, 17, 19, 18, 20],d = 2) == 19\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 10\n assert candidate(arr = [5, 1, 4, 1, 3, 1, 2, 1],d = 2) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 5) == 20\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 5) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 9) == 10\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 3) == 20\n assert candidate(arr = [5, 6, 1, 2, 9, 3, 4, 8, 7, 10],d = 3) == 4\n assert candidate(arr = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],d = 4) == 2\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],d = 5) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 4) == 15\n assert candidate(arr = [1, 6, 5, 4, 6, 1, 2, 3, 4, 6, 5, 4, 6, 1, 2, 3, 4, 6, 5, 4],d = 2) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4],d = 4) == 5\n assert candidate(arr = [1, 6, 3, 5, 2, 4, 7, 8, 10, 9],d = 4) == 6\n assert candidate(arr = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55],d = 5) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 5) == 10\n assert candidate(arr = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],d = 5) == 10\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12],d = 3) == 11\n assert candidate(arr = [3, 1, 2, 1, 3, 1, 2, 1, 3],d = 1) == 2\n assert candidate(arr = [1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10],d = 5) == 9\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 4) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 1) == 1\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9],d = 4) == 9\n assert candidate(arr = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100],d = 5) == 2\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],d = 3) == 6\n assert candidate(arr = [10, 2, 8, 4, 7, 9, 3, 1, 5, 6],d = 4) == 5\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2],d = 2) == 3\n assert candidate(arr = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],d = 5) == 6\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 3) == 10\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],d = 4) == 10\n assert candidate(arr = [7, 2, 8, 9, 1, 3, 5, 6, 4],d = 3) == 4\n assert candidate(arr = [5, 1, 3, 4, 2, 6, 7, 8, 9, 10],d = 2) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],d = 3) == 6\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],d = 2) == 9\n assert candidate(arr = [5, 1, 3, 2, 4, 6, 7, 8, 10, 9],d = 2) == 7\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],d = 2) == 2\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1],d = 2) == 6\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7, 8, 9],d = 3) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],d = 4) == 5\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],d = 3) == 8\n assert candidate(arr = [8, 7, 6, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 7, 8],d = 3) == 5\n assert candidate(arr = [3, 5, 1, 2, 4, 6, 8, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 4) == 18\n assert candidate(arr = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12, 9, 13, 10],d = 4) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 10\n assert candidate(arr = [1, 5, 5, 5, 1, 5, 5, 5, 1],d = 2) == 2\n assert candidate(arr = [2, 1, 5, 3, 4, 8, 6, 7, 10, 9],d = 3) == 5\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 10, 1, 9, 2, 8, 3, 7, 4, 6, 5],d = 5) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 3) == 10\n assert candidate(arr = [8, 3, 5, 2, 4, 7, 6, 1, 10, 9],d = 5) == 5\n assert candidate(arr = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10],d = 3) == 10\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5],d = 2) == 2\n assert candidate(arr = [50, 40, 30, 20, 10, 1, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1],d = 5) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 5) == 20\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 3) == 10\n", "comparison": "exact"}, "public_tests": ["[6,4,14,6,8,13,9,7,10,6,12]\n2", "[3,3,3,3,3]\n3", "[7,6,5,4,3,2,1]\n1"], "hints": ["Use dynamic programming. dp[i] is max jumps you can do starting from index i. Answer is max(dp[i]).", "dp[i] = 1 + max (dp[j]) where j is all indices you can reach from i."], "metadata": {"canonical_parameter_names": ["arr", "d"], "leetcode_dataset_entry_point": "Solution().maxJumps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:18+00:00", "tests_total": 122, "tests_dropped": 4, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "sorting"]}, "language": "java", "interface": {"raw_signature": "public int maxJumps(int[] arr, int d) {", "container": "Solution", "callable": "maxJumps", "parameters": [{"name": "arr", "type": "int[]"}, {"name": "d", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1342, "task_id": "number-of-steps-to-reduce-a-number-to-zero", "difficulty": "Easy", "problem_description": "Given an integer num, return the number of steps to reduce it to zero.\n\nIn one step, if the current number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it.\n\nExample 1:\n\nInput: num = 14\nOutput: 6\nExplanation:\nStep 1) 14 is even; divide by 2 and obtain 7.\nStep 2) 7 is odd; subtract 1 and obtain 6.\nStep 3) 6 is even; divide by 2 and obtain 3.\nStep 4) 3 is odd; subtract 1 and obtain 2.\nStep 5) 2 is even; divide by 2 and obtain 1.\nStep 6) 1 is odd; subtract 1 and obtain 0.\n\nExample 2:\n\nInput: num = 8\nOutput: 4\nExplanation:\nStep 1) 8 is even; divide by 2 and obtain 4.\nStep 2) 4 is even; divide by 2 and obtain 2.\nStep 3) 2 is even; divide by 2 and obtain 1.\nStep 4) 1 is odd; subtract 1 and obtain 0.\n\nExample 3:\n\nInput: num = 123\nOutput: 12\n\nConstraints:\n\n- 0 <= num <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 14) == 6\n assert candidate(num = 1000000) == 26\n assert candidate(num = 8) == 4\n assert candidate(num = 65535) == 31\n assert candidate(num = 0) == 0\n assert candidate(num = 2) == 2\n assert candidate(num = 1) == 1\n assert candidate(num = 123) == 12\n assert candidate(num = 8191) == 25\n assert candidate(num = 750000) == 29\n assert candidate(num = 500000) == 25\n assert candidate(num = 131072) == 18\n assert candidate(num = 1023) == 19\n assert candidate(num = 777777) == 31\n assert candidate(num = 127) == 13\n assert candidate(num = 888888) == 27\n assert candidate(num = 16384) == 15\n assert candidate(num = 31) == 9\n assert candidate(num = 100001) == 23\n assert candidate(num = 8192) == 14\n assert candidate(num = 15) == 7\n assert candidate(num = 32768) == 16\n assert candidate(num = 63) == 11\n assert candidate(num = 3125) == 17\n assert candidate(num = 131071) == 33\n assert candidate(num = 16383) == 27\n assert candidate(num = 665772) == 27\n assert candidate(num = 4096) == 13\n assert candidate(num = 511) == 17\n assert candidate(num = 524288) == 20\n assert candidate(num = 7) == 5\n assert candidate(num = 543210) == 28\n assert candidate(num = 567890) == 27\n assert candidate(num = 255) == 15\n assert candidate(num = 1024) == 11\n assert candidate(num = 100000) == 22\n assert candidate(num = 54321) == 22\n assert candidate(num = 262143) == 35\n assert candidate(num = 123456) == 22\n assert candidate(num = 999999) == 31\n assert candidate(num = 32767) == 29\n assert candidate(num = 65536) == 17\n assert candidate(num = 2048) == 12\n assert candidate(num = 3) == 3\n assert candidate(num = 987654) == 27\n", "comparison": "exact"}, "public_tests": ["14", "8", "123"], "hints": ["Simulate the process to get the final answer."], "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().numberOfSteps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:20+00:00", "tests_total": 59, "tests_dropped": 14, "flags": [], "topic_tags": ["math", "bit-manipulation"]}, "language": "java", "interface": {"raw_signature": "public int numberOfSteps(int num) {", "container": "Solution", "callable": "numberOfSteps", "parameters": [{"name": "num", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1343, "task_id": "number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold", "difficulty": "Medium", "problem_description": "Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.\n\nExample 1:\n\nInput: arr = [2,2,2,2,5,5,5,8], k = 3, threshold = 4\nOutput: 3\nExplanation: Sub-arrays [2,5,5],[5,5,5] and [5,5,8] have averages 4, 5 and 6 respectively. All other sub-arrays of size 3 have averages less than 4 (the threshold).\n\nExample 2:\n\nInput: arr = [11,13,17,23,29,31,7,5,2,3], k = 3, threshold = 5\nOutput: 6\nExplanation: The first 6 sub-arrays of size 3 have averages greater than 5. Note that averages are not integers.\n\nConstraints:\n\n- 1 <= arr.length <= 10^5\n- 1 <= arr[i] <= 10^4\n- 1 <= k <= arr.length\n- 0 <= threshold <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 2, 2, 2, 5, 5, 5, 8],k = 3,threshold = 4) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5],k = 3,threshold = 5) == 5\n assert candidate(arr = [10000, 10000, 10000],k = 3,threshold = 10000) == 1\n assert candidate(arr = [1, 2, 3, 4, 5],k = 2,threshold = 3) == 2\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000],k = 1,threshold = 10000) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1],k = 2,threshold = 1) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4,threshold = 5) == 4\n assert candidate(arr = [10, 20, 30, 40, 50],k = 1,threshold = 10) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,threshold = 1) == 6\n assert candidate(arr = [5, 5, 5, 5, 5],k = 5,threshold = 5) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5],k = 4,threshold = 6) == 0\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5],k = 5,threshold = 5) == 4\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4,threshold = 5) == 3\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000],k = 5,threshold = 10000) == 1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3],k = 4,threshold = 3) == 4\n assert candidate(arr = [1, 1, 1, 1, 1],k = 2,threshold = 1) == 4\n assert candidate(arr = [1, 2, 3, 4, 5],k = 2,threshold = 2) == 3\n assert candidate(arr = [11, 13, 17, 23, 29, 31, 7, 5, 2, 3],k = 3,threshold = 5) == 6\n assert candidate(arr = [10, 20, 30, 40, 50],k = 4,threshold = 25) == 2\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 6,threshold = 15) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 10,threshold = 13) == 8\n assert candidate(arr = [1, 3, 2, 6, 5, 4, 8, 7, 9, 10],k = 3,threshold = 6) == 3\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 7,threshold = 7) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,threshold = 10.5) == 6\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 2,threshold = 55) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5) == 4\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 3,threshold = 3) == 6\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6,threshold = 10) == 8\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 6,threshold = 10) == 8\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5,threshold = 5) == 9\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 20,threshold = 9) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10,threshold = 5) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 7,threshold = 10) == 8\n assert candidate(arr = [2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],k = 6,threshold = 3) == 8\n assert candidate(arr = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],k = 10,threshold = 25) == 6\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 20,threshold = 5000) == 1\n assert candidate(arr = [3, 6, 1, 3, 9, 6, 1, 7, 8, 2],k = 3,threshold = 5) == 4\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5,threshold = 5) == 9\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 10,threshold = 3) == 11\n assert candidate(arr = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 15,threshold = 50) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 19,threshold = 1) == 2\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 11,threshold = 800) == 3\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5,threshold = 5) == 4\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 7,threshold = 5000) == 6\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 10,threshold = 5000) == 6\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 3,threshold = 10) == 15\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,threshold = 1) == 11\n assert candidate(arr = [4999, 5000, 4999, 5000, 4999, 5000, 4999, 5000, 4999, 5000],k = 3,threshold = 5000) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5.5) == 3\n assert candidate(arr = [10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000, 1],k = 5,threshold = 5000) == 3\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 5,threshold = 1.5) == 8\n assert candidate(arr = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 3,threshold = 10) == 14\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2,threshold = 5) == 5\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 3,threshold = 8) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5) == 11\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10,threshold = 55) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 7,threshold = 15) == 5\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 10,threshold = 10000) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 5,threshold = 12) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,threshold = 10) == 6\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85],k = 7,threshold = 92) == 5\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5,threshold = 20) == 8\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5,threshold = 15) == 11\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3,threshold = 55) == 4\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 8,threshold = 9000) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 6,threshold = 10) == 8\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5,threshold = 550) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7,threshold = 1) == 9\n assert candidate(arr = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6,threshold = 4) == 9\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],k = 3,threshold = 2) == 18\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 5,threshold = 5000) == 6\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10,threshold = 10.5) == 6\n assert candidate(arr = [10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000, 1],k = 2,threshold = 5000) == 9\n assert candidate(arr = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],k = 7,threshold = 15) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,threshold = 1) == 73\n assert candidate(arr = [2, 3, 1, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 6,threshold = 5) == 9\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,threshold = 1) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5,threshold = 10) == 9\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 7,threshold = 15) == 5\n assert candidate(arr = [40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2],k = 10,threshold = 15) == 9\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 5,threshold = 15) == 6\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1],k = 4,threshold = 2) == 18\n assert candidate(arr = [1, 1, 1, 1, 10, 1, 1, 1, 1, 10, 1, 1, 1, 1, 10],k = 3,threshold = 3) == 7\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 6,threshold = 55) == 3\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4,threshold = 5) == 4\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4,threshold = 55) == 4\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5,threshold = 450) == 4\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 3,threshold = 15) == 12\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4,threshold = 5) == 4\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 6,threshold = 10) == 3\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 6,threshold = 500) == 3\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 9,threshold = 9999) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10,threshold = 8) == 3\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 4,threshold = 15) == 4\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 8,threshold = 100) == 9\n assert candidate(arr = [3, 5, 1, 8, 7, 9, 4, 6, 2, 10, 11, 12],k = 5,threshold = 6) == 5\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2,threshold = 500) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,threshold = 0.5) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 6) == 3\n", "comparison": "exact"}, "public_tests": ["[2,2,2,2,5,5,5,8]\n3\n4", "[11,13,17,23,29,31,7,5,2,3]\n3\n5"], "hints": ["Start with a window of size K and test its average against the threshold.", "Keep moving the window by one element maintaining its size k until you cover the whole array. Count the number of windows that have an average greater than or equal to the threshold."], "metadata": {"canonical_parameter_names": ["arr", "k", "threshold"], "leetcode_dataset_entry_point": "Solution().numOfSubarrays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:22+00:00", "tests_total": 108, "tests_dropped": 8, "flags": [], "topic_tags": ["array", "sliding-window"]}, "language": "java", "interface": {"raw_signature": "public int numOfSubarrays(int[] arr, int k, int threshold) {", "container": "Solution", "callable": "numOfSubarrays", "parameters": [{"name": "arr", "type": "int[]"}, {"name": "k", "type": "int"}, {"name": "threshold", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1343, "task_id": "number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold", "difficulty": "Medium", "problem_description": "Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.\n\nExample 1:\n\nInput: arr = [2,2,2,2,5,5,5,8], k = 3, threshold = 4\nOutput: 3\nExplanation: Sub-arrays [2,5,5],[5,5,5] and [5,5,8] have averages 4, 5 and 6 respectively. All other sub-arrays of size 3 have averages less than 4 (the threshold).\n\nExample 2:\n\nInput: arr = [11,13,17,23,29,31,7,5,2,3], k = 3, threshold = 5\nOutput: 6\nExplanation: The first 6 sub-arrays of size 3 have averages greater than 5. Note that averages are not integers.\n\nConstraints:\n\n- 1 <= arr.length <= 10^5\n- 1 <= arr[i] <= 10^4\n- 1 <= k <= arr.length\n- 0 <= threshold <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 2, 2, 2, 5, 5, 5, 8],k = 3,threshold = 4) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5],k = 3,threshold = 5) == 5\n assert candidate(arr = [10000, 10000, 10000],k = 3,threshold = 10000) == 1\n assert candidate(arr = [1, 2, 3, 4, 5],k = 2,threshold = 3) == 2\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000],k = 1,threshold = 10000) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1],k = 2,threshold = 1) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4,threshold = 5) == 4\n assert candidate(arr = [10, 20, 30, 40, 50],k = 1,threshold = 10) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,threshold = 1) == 6\n assert candidate(arr = [5, 5, 5, 5, 5],k = 5,threshold = 5) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5],k = 4,threshold = 6) == 0\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5],k = 5,threshold = 5) == 4\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4,threshold = 5) == 3\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000],k = 5,threshold = 10000) == 1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3],k = 4,threshold = 3) == 4\n assert candidate(arr = [1, 1, 1, 1, 1],k = 2,threshold = 1) == 4\n assert candidate(arr = [1, 2, 3, 4, 5],k = 2,threshold = 2) == 3\n assert candidate(arr = [11, 13, 17, 23, 29, 31, 7, 5, 2, 3],k = 3,threshold = 5) == 6\n assert candidate(arr = [10, 20, 30, 40, 50],k = 4,threshold = 25) == 2\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 6,threshold = 15) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 10,threshold = 13) == 8\n assert candidate(arr = [1, 3, 2, 6, 5, 4, 8, 7, 9, 10],k = 3,threshold = 6) == 3\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 7,threshold = 7) == 9\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 2,threshold = 55) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5) == 4\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 3,threshold = 3) == 6\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6,threshold = 10) == 8\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 6,threshold = 10) == 8\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5,threshold = 5) == 9\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 20,threshold = 9) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10,threshold = 5) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 7,threshold = 10) == 8\n assert candidate(arr = [2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],k = 6,threshold = 3) == 8\n assert candidate(arr = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],k = 10,threshold = 25) == 6\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 20,threshold = 5000) == 1\n assert candidate(arr = [3, 6, 1, 3, 9, 6, 1, 7, 8, 2],k = 3,threshold = 5) == 4\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5,threshold = 5) == 9\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 10,threshold = 3) == 11\n assert candidate(arr = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 15,threshold = 50) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 19,threshold = 1) == 2\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 11,threshold = 800) == 3\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5,threshold = 5) == 4\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 7,threshold = 5000) == 6\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 10,threshold = 5000) == 6\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 3,threshold = 10) == 15\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,threshold = 1) == 11\n assert candidate(arr = [4999, 5000, 4999, 5000, 4999, 5000, 4999, 5000, 4999, 5000],k = 3,threshold = 5000) == 0\n assert candidate(arr = [10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000, 1],k = 5,threshold = 5000) == 3\n assert candidate(arr = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 3,threshold = 10) == 14\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2,threshold = 5) == 5\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 3,threshold = 8) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5) == 11\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10,threshold = 55) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 7,threshold = 15) == 5\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 10,threshold = 10000) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 5,threshold = 12) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,threshold = 10) == 6\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85],k = 7,threshold = 92) == 5\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5,threshold = 20) == 8\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5,threshold = 15) == 11\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3,threshold = 55) == 4\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 8,threshold = 9000) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 6,threshold = 10) == 8\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5,threshold = 550) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7,threshold = 1) == 9\n assert candidate(arr = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6,threshold = 4) == 9\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],k = 3,threshold = 2) == 18\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 5,threshold = 5000) == 6\n assert candidate(arr = [10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000, 1],k = 2,threshold = 5000) == 9\n assert candidate(arr = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],k = 7,threshold = 15) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,threshold = 1) == 73\n assert candidate(arr = [2, 3, 1, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 6,threshold = 5) == 9\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,threshold = 1) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5,threshold = 10) == 9\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 7,threshold = 15) == 5\n assert candidate(arr = [40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2],k = 10,threshold = 15) == 9\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 5,threshold = 15) == 6\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1],k = 4,threshold = 2) == 18\n assert candidate(arr = [1, 1, 1, 1, 10, 1, 1, 1, 1, 10, 1, 1, 1, 1, 10],k = 3,threshold = 3) == 7\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 6,threshold = 55) == 3\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4,threshold = 5) == 4\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4,threshold = 55) == 4\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5,threshold = 450) == 4\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 3,threshold = 15) == 12\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4,threshold = 5) == 4\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 6,threshold = 10) == 3\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 6,threshold = 500) == 3\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 9,threshold = 9999) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10,threshold = 8) == 3\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 4,threshold = 15) == 4\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 8,threshold = 100) == 9\n assert candidate(arr = [3, 5, 1, 8, 7, 9, 4, 6, 2, 10, 11, 12],k = 5,threshold = 6) == 5\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2,threshold = 500) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 6) == 3\n", "comparison": "exact"}, "public_tests": ["[2,2,2,2,5,5,5,8]\n3\n4", "[11,13,17,23,29,31,7,5,2,3]\n3\n5"], "hints": ["Start with a window of size K and test its average against the threshold.", "Keep moving the window by one element maintaining its size k until you cover the whole array. Count the number of windows that have an average greater than or equal to the threshold."], "metadata": {"canonical_parameter_names": ["arr", "k", "threshold"], "leetcode_dataset_entry_point": "Solution().numOfSubarrays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:22+00:00", "tests_total": 108, "tests_dropped": 13, "flags": [], "topic_tags": ["array", "sliding-window"]}, "language": "java", "interface": {"raw_signature": "public int numOfSubarrays(int[] arr, int k, int threshold) {", "container": "Solution", "callable": "numOfSubarrays", "parameters": [{"name": "arr", "type": "int[]"}, {"name": "k", "type": "int"}, {"name": "threshold", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1344, "task_id": "angle-between-hands-of-a-clock", "difficulty": "Medium", "problem_description": "Given two numbers, hour and minutes, return the smaller angle (in degrees) formed between the hour and the minute hand.\n\nAnswers within 10^-5 of the actual value will be accepted as correct.\n\nExample 1:\n\nInput: hour = 12, minutes = 30\nOutput: 165\n\nExample 2:\n\nInput: hour = 3, minutes = 30\nOutput: 75\n\nExample 3:\n\nInput: hour = 3, minutes = 15\nOutput: 7.5\n\nConstraints:\n\n- 1 <= hour <= 12\n- 0 <= minutes <= 59\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(hour=3, minutes=30), 75.0)\n assert answers_match(candidate(hour=11, minutes=59), 5.5)\n assert answers_match(candidate(hour=3, minutes=15), 7.5)\n assert answers_match(candidate(hour=7, minutes=30), 45.0)\n assert answers_match(candidate(hour=11, minutes=0), 30.0)\n assert answers_match(candidate(hour=2, minutes=10), 5.0)\n assert answers_match(candidate(hour=12, minutes=30), 165.0)\n assert answers_match(candidate(hour=1, minutes=0), 30.0)\n assert answers_match(candidate(hour=1, minutes=55), 87.5)\n assert answers_match(candidate(hour=9, minutes=45), 22.5)\n assert answers_match(candidate(hour=1, minutes=5), 2.5)\n assert answers_match(candidate(hour=12, minutes=0), 0.0)\n assert answers_match(candidate(hour=6, minutes=0), 180.0)\n assert answers_match(candidate(hour=7, minutes=10), 155.0)\n assert answers_match(candidate(hour=7, minutes=35), 17.5)\n assert answers_match(candidate(hour=2, minutes=5), 32.5)\n assert answers_match(candidate(hour=6, minutes=15), 97.5)\n assert answers_match(candidate(hour=5, minutes=0), 150.0)\n assert answers_match(candidate(hour=2, minutes=47), 161.5)\n assert answers_match(candidate(hour=4, minutes=0), 120.0)\n assert answers_match(candidate(hour=10, minutes=25), 162.5)\n assert answers_match(candidate(hour=8, minutes=23), 113.5)\n assert answers_match(candidate(hour=11, minutes=15), 112.5)\n assert answers_match(candidate(hour=4, minutes=50), 155.0)\n assert answers_match(candidate(hour=8, minutes=18), 141.0)\n assert answers_match(candidate(hour=8, minutes=20), 130.0)\n assert answers_match(candidate(hour=10, minutes=31), 129.5)\n assert answers_match(candidate(hour=5, minutes=10), 95.0)\n assert answers_match(candidate(hour=12, minutes=15), 82.5)\n assert answers_match(candidate(hour=5, minutes=14), 73.0)\n assert answers_match(candidate(hour=5, minutes=45), 97.5)\n assert answers_match(candidate(hour=12, minutes=59), 35.5)\n assert answers_match(candidate(hour=12, minutes=1), 5.5)\n assert answers_match(candidate(hour=10, minutes=10), 115.0)\n assert answers_match(candidate(hour=7, minutes=22), 89.0)\n assert answers_match(candidate(hour=12, minutes=47), 101.5)\n assert answers_match(candidate(hour=2, minutes=40), 160.0)\n assert answers_match(candidate(hour=5, minutes=55), 152.5)\n assert answers_match(candidate(hour=7, minutes=0), 150.0)\n assert answers_match(candidate(hour=4, minutes=48), 144.0)\n assert answers_match(candidate(hour=6, minutes=37), 23.5)\n assert answers_match(candidate(hour=2, minutes=24), 72.0)\n assert answers_match(candidate(hour=8, minutes=40), 20.0)\n assert answers_match(candidate(hour=5, minutes=15), 67.5)\n assert answers_match(candidate(hour=4, minutes=10), 65.0)\n assert answers_match(candidate(hour=8, minutes=50), 35.0)\n assert answers_match(candidate(hour=4, minutes=40), 100.0)\n assert answers_match(candidate(hour=4, minutes=25), 17.5)\n assert answers_match(candidate(hour=1, minutes=37), 173.5)\n assert answers_match(candidate(hour=3, minutes=47), 168.5)\n assert answers_match(candidate(hour=10, minutes=48), 36.0)\n assert answers_match(candidate(hour=8, minutes=32), 64.0)\n assert answers_match(candidate(hour=1, minutes=10), 25.0)\n assert answers_match(candidate(hour=7, minutes=5), 177.5)\n assert answers_match(candidate(hour=6, minutes=30), 15.0)\n assert answers_match(candidate(hour=7, minutes=59), 114.5)\n assert answers_match(candidate(hour=8, minutes=28), 86.0)\n assert answers_match(candidate(hour=9, minutes=27), 121.5)\n assert answers_match(candidate(hour=4, minutes=55), 177.5)\n assert answers_match(candidate(hour=10, minutes=35), 107.5)\n assert answers_match(candidate(hour=7, minutes=32), 34.0)\n assert answers_match(candidate(hour=6, minutes=33), 1.5)\n assert answers_match(candidate(hour=10, minutes=20), 170.0)\n assert answers_match(candidate(hour=1, minutes=50), 115.0)\n assert answers_match(candidate(hour=5, minutes=37), 53.5)\n assert answers_match(candidate(hour=5, minutes=47), 108.5)\n assert answers_match(candidate(hour=11, minutes=5), 57.5)\n assert answers_match(candidate(hour=2, minutes=30), 105.0)\n assert answers_match(candidate(hour=2, minutes=20), 50.0)\n assert answers_match(candidate(hour=12, minutes=45), 112.5)\n assert answers_match(candidate(hour=8, minutes=0), 120.0)\n assert answers_match(candidate(hour=7, minutes=47), 48.5)\n", "comparison": "float"}, "public_tests": ["12\n30", "3\n30", "3\n15"], "hints": ["The tricky part is determining how the minute hand affects the position of the hour hand.", "Calculate the angles separately then find the difference."], "metadata": {"canonical_parameter_names": ["hour", "minutes"], "leetcode_dataset_entry_point": "Solution().angleClock", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:24+00:00", "tests_total": 72, "tests_dropped": 0, "flags": ["decimal_answer", "has_images"], "topic_tags": ["math"]}, "language": "java", "interface": {"raw_signature": "public double angleClock(int hour, int minutes) {", "container": "Solution", "callable": "angleClock", "parameters": [{"name": "hour", "type": "int"}, {"name": "minutes", "type": "int"}], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1345, "task_id": "jump-game-iv", "difficulty": "Hard", "problem_description": "Given an array of integers arr, you are initially positioned at the first index of the array.\n\nIn one step you can jump from index i to index:\n\n- i + 1 where: i + 1 < arr.length.\n- i - 1 where: i - 1 >= 0.\n- j where: arr[i] == arr[j] and i != j.\n\nReturn the minimum number of steps to reach the last index of the array.\n\nNotice that you can not jump outside of the array at any time.\n\nExample 1:\n\nInput: arr = [100,-23,-23,404,100,23,23,23,3,404]\nOutput: 3\nExplanation: You need three jumps from index 0 --> 4 --> 3 --> 9. Note that index 9 is the last index of the array.\n\nExample 2:\n\nInput: arr = [7]\nOutput: 0\nExplanation: Start index is the last index. You do not need to jump.\n\nExample 3:\n\nInput: arr = [7,6,9,6,9,6,9,7]\nOutput: 1\nExplanation: You can jump directly from index 0 to index 7 which is last index of the array.\n\nConstraints:\n\n- 1 <= arr.length <= 5 * 10^4\n- -10^8 <= arr[i] <= 10^8\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [11, 22, 7, 7, 7, 7, 7, 7, 7, 22, 13]) == 3\n assert candidate(arr = [6, 1, 9, 6, 9, 1, 9, 6, 1, 9]) == 3\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 11, 11, 11, 11, 11, 11]) == 3\n assert candidate(arr = [7, 6, 9, 6, 9, 6, 9, 7]) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 1]) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 1\n assert candidate(arr = [1, 2, 3, 5, 3, 2, 1, 2, 3, 4]) == 4\n assert candidate(arr = [7]) == 0\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(arr = [100, -23, -23, 404, 100, 23, 23, 23, 3, 404]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 9\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 4\n assert candidate(arr = [7, 7, 7, 7, 11, 11, 11, 11, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1]) == 1\n assert candidate(arr = [7, 7, 7, 7, 12, 7, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [10, 20, 30, 20, 10, 10, 20, 30, 10]) == 1\n assert candidate(arr = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 3\n assert candidate(arr = [6, 1, 9, 8, 4, 10, 9, 4, 10, 4, 10, 9, 10, 9, 8, 10, 9, 4, 10, 9, 10, 9, 8, 10, 9, 4, 10, 9]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [10, 22, 10, 20, 11, 22, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10, 100, 10, 110, 10, 120, 10, 130, 10, 140, 10, 150, 10, 160, 10, 170, 10, 180, 10, 190, 10, 200]) == 2\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6]) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(arr = [1, 3, 5, 3, 1, 2, 4, 2, 6, 4, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19]) == 37\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n", "comparison": "exact"}, "public_tests": ["[100,-23,-23,404,100,23,23,23,3,404]", "[7]", "[7,6,9,6,9,6,9,7]"], "hints": ["Build a graph of n nodes where nodes are the indices of the array and edges for node i are nodes i+1, i-1, j where arr[i] == arr[j].", "Start bfs from node 0 and keep distance. The answer is the distance when you reach node n-1."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().minJumps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:27+00:00", "tests_total": 60, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "breadth-first-search"]}, "language": "java", "interface": {"raw_signature": "public int minJumps(int[] arr) {", "container": "Solution", "callable": "minJumps", "parameters": [{"name": "arr", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1346, "task_id": "check-if-n-and-its-double-exist", "difficulty": "Easy", "problem_description": "Given an array arr of integers, check if there exist two indices i and j such that :\n\n- i != j\n- 0 <= i, j < arr.length\n- arr[i] == 2 * arr[j]\n\nExample 1:\n\nInput: arr = [10,2,5,3]\nOutput: true\nExplanation: For i = 0 and j = 2, arr[i] == 10 == 2 * 5 == 2 * arr[j]\n\nExample 2:\n\nInput: arr = [3,1,7,11]\nOutput: false\nExplanation: There is no i and j that satisfy the conditions.\n\nConstraints:\n\n- 2 <= arr.length <= 500\n- -10^3 <= arr[i] <= 10^3\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 4, 6, 8, 10]) == True\n assert candidate(arr = [6, 10, 1, 0, -3, 3]) == True\n assert candidate(arr = [-3, -6, -1, 0, 1, 2, 3]) == True\n assert candidate(arr = [-2, -4, -6, -8, -10]) == True\n assert candidate(arr = [100, 200, 300, 400, 500]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64]) == True\n assert candidate(arr = [-10, -20, -5, -3]) == True\n assert candidate(arr = [1, 2, 3, 6, 12]) == True\n assert candidate(arr = [0, 0]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(arr = [-10, 10]) == False\n assert candidate(arr = [10, 2, 5, 3]) == True\n assert candidate(arr = [1, 2, 3, 4, 5]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(arr = [1, 2, 4, 8, 16]) == True\n assert candidate(arr = [-2, 0, 10, -19, 4, 6, -8]) == False\n assert candidate(arr = [1, 3, 5, 7, 9]) == False\n assert candidate(arr = [3, 1, 7, 11]) == False\n assert candidate(arr = [-10, -20, -30, -40, -50]) == True\n assert candidate(arr = [-10, -5, -3, -1, 2]) == True\n assert candidate(arr = [10, 5, 15, 20, 25]) == True\n assert candidate(arr = [1, -1, 2, -2, 4, -4, 8, -8, 16, -16]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8]) == True\n assert candidate(arr = [2, 1, 4, 2, 8, 4, 16]) == True\n assert candidate(arr = [1, 2, 3, 5, 6, 10, 20, 40]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == True\n assert candidate(arr = [-100, -50, -25, -12, -6, -3, -1, 0, 1, 2, 4]) == True\n assert candidate(arr = [4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -10, -20]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256]) == True\n assert candidate(arr = [0, 0, 0, 0]) == True\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1]) == True\n assert candidate(arr = [101, 202, 50, 25, 12, 6, 3]) == True\n assert candidate(arr = [1000, 501, 250, 125, 62, 31, 15, 7, 3, 1]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 60]) == True\n assert candidate(arr = [-1, 2, -3, 6, -4, 8]) == False\n assert candidate(arr = [-10, -20, 5, 3, 15]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 250, 125]) == True\n assert candidate(arr = [-1, -2, -3, -6, -12]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == True\n assert candidate(arr = [100, 50, 25, 12.5, 6.25, 3.125, 1.5625]) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 0, 2, 0, 4, 0, 8, 0]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200]) == True\n assert candidate(arr = [3, 6, 9, 18, 27, 54, 81]) == True\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56]) == True\n assert candidate(arr = [1, 2, 3, 6, 9, 18, 36, 72]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5]) == True\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 50, 100]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == True\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == True\n assert candidate(arr = [1, 2, 3, 6, 12, 24, 48, 96, 192, 384]) == True\n assert candidate(arr = [-1, -2, -4, -8, -16]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == True\n assert candidate(arr = [0, 0, 1, 2, 4]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 38]) == True\n assert candidate(arr = [1, 2, 3, 5, 6, 10, 15, 20, 30, 60]) == True\n assert candidate(arr = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6]) == True\n assert candidate(arr = [-2, 2, -4, 4, -8, 8, -16, 16]) == True\n assert candidate(arr = [-10, -5, -15, -20, -25]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == True\n assert candidate(arr = [-1, 1, -2, 2, -4, 4, 8, -8]) == True\n assert candidate(arr = [0, 1, 2, 3, 6, 12, 24, 48, 96]) == True\n assert candidate(arr = [13, 26, 52, 104, 208, 416]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(arr = [-5, 10, -15, 20, -25, 50, -75]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 50, 75]) == True\n assert candidate(arr = [6, 12, 18, 24, 48]) == True\n assert candidate(arr = [1, 0, 2, 0, 4, 0, 8, 0, 16, 0]) == True\n assert candidate(arr = [1, 2, 3, 6, 12, 24, 48, 96]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 40]) == True\n assert candidate(arr = [1000, -500, 250, -125, 62.5, 31.25]) == True\n assert candidate(arr = [-1, 2, -2, 4, -4, 8]) == True\n assert candidate(arr = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8]) == True\n assert candidate(arr = [15, 30, 45, 90, 135, 270]) == True\n assert candidate(arr = [-10, -5, -1, -2, -3, -4, -6, -8, -12, -16]) == True\n assert candidate(arr = [10, 20, 40, 80, 160, 320, 640]) == True\n assert candidate(arr = [-10, -5, 0, 5, 10]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50, -100, -200, -300]) == True\n assert candidate(arr = [-3, -6, -9, -12, -15, -18, -21, -24]) == True\n assert candidate(arr = [3, 6, 12, 24, 48, 96, 192, 384]) == True\n assert candidate(arr = [0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(arr = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == True\n assert candidate(arr = [-5, -10, -15, -20, -25, -30, -35, -40, -45]) == True\n assert candidate(arr = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 10]) == True\n assert candidate(arr = [11, 22, 44, 88, 176, 352, 704]) == True\n assert candidate(arr = [0, 0, 0, 0, 0]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24]) == True\n assert candidate(arr = [100, 51, 25, 12, 6, 3, 1]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 17, 19, 21]) == False\n assert candidate(arr = [0, 1, 2, 4, 8, 16, 32]) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 3, 9, 27, 81, 243, 729]) == False\n assert candidate(arr = [0, 1, 2, 3, 4, 8, 16]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 50, 100]) == True\n assert candidate(arr = [9, 18, 36, 72, 144, 288, 576]) == True\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 18, 36, 72]) == True\n assert candidate(arr = [7, 14, 28, 56, 112, 224, 448]) == True\n assert candidate(arr = [1000, 500, 250, 125, 62.5]) == True\n assert candidate(arr = [1, 2, 3, 6, 12, 24, 48, 96, 192, 384, 768]) == True\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1, 0]) == True\n assert candidate(arr = [1, 5, 10, 20, 25, 50, 100]) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(arr = [-2, -4, -6, -8, -16]) == True\n assert candidate(arr = [-10, -20, -30, -200, -300, -150]) == True\n assert candidate(arr = [0, 1, 2, 4, 8, 16, 32, 64]) == True\n assert candidate(arr = [1, 2, 3, 5, 6, 10, 15, 20, 30, 60, 120, 240]) == True\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1, 0, -1, -2, -4]) == True\n assert candidate(arr = [7, 14, 28, 56, 112, 224]) == True\n assert candidate(arr = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50]) == True\n assert candidate(arr = [7, 14, 28, 56, 112, 224, 448, 896]) == True\n assert candidate(arr = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 115]) == True\n assert candidate(arr = [10, 5, 15, 20, 2, 25, 50]) == True\n assert candidate(arr = [-2, -4, -1, -3, -5, -10]) == True\n assert candidate(arr = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == True\n assert candidate(arr = [-1, -2, -4, -8, -16, -32, -64]) == True\n assert candidate(arr = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32]) == True\n assert candidate(arr = [1, 2, 3, 6, 9, 18, 27, 54]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == True\n assert candidate(arr = [1, 0, 2, 0, 4, 0, 8, 0, 16, 0, 32, 0, 64, 0, 128, 0]) == True\n assert candidate(arr = [-2, -4, -8, -16, -32, -64, -128]) == True\n", "comparison": "exact"}, "public_tests": ["[10,2,5,3]", "[3,1,7,11]"], "hints": ["Loop from i = 0 to arr.length, maintaining in a hashTable the array elements from [0, i - 1].", "On each step of the loop check if we have seen the element 2 * arr[i] so far.", "Also check if we have seen arr[i] / 2 in case arr[i] % 2 == 0."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().checkIfExist", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:29+00:00", "tests_total": 147, "tests_dropped": 16, "flags": [], "topic_tags": ["array", "hash-table", "two-pointers", "binary-search", "sorting"]}, "language": "java", "interface": {"raw_signature": "public boolean checkIfExist(int[] arr) {", "container": "Solution", "callable": "checkIfExist", "parameters": [{"name": "arr", "type": "int[]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1346, "task_id": "check-if-n-and-its-double-exist", "difficulty": "Easy", "problem_description": "Given an array arr of integers, check if there exist two indices i and j such that :\n\n- i != j\n- 0 <= i, j < arr.length\n- arr[i] == 2 * arr[j]\n\nExample 1:\n\nInput: arr = [10,2,5,3]\nOutput: true\nExplanation: For i = 0 and j = 2, arr[i] == 10 == 2 * 5 == 2 * arr[j]\n\nExample 2:\n\nInput: arr = [3,1,7,11]\nOutput: false\nExplanation: There is no i and j that satisfy the conditions.\n\nConstraints:\n\n- 2 <= arr.length <= 500\n- -10^3 <= arr[i] <= 10^3\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 4, 6, 8, 10]) == True\n assert candidate(arr = [6, 10, 1, 0, -3, 3]) == True\n assert candidate(arr = [-3, -6, -1, 0, 1, 2, 3]) == True\n assert candidate(arr = [-2, -4, -6, -8, -10]) == True\n assert candidate(arr = [100, 200, 300, 400, 500]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64]) == True\n assert candidate(arr = [-10, -20, -5, -3]) == True\n assert candidate(arr = [1, 2, 3, 6, 12]) == True\n assert candidate(arr = [0, 0]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(arr = [-10, 10]) == False\n assert candidate(arr = [10, 2, 5, 3]) == True\n assert candidate(arr = [1, 2, 3, 4, 5]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(arr = [1, 2, 4, 8, 16]) == True\n assert candidate(arr = [-2, 0, 10, -19, 4, 6, -8]) == False\n assert candidate(arr = [1, 3, 5, 7, 9]) == False\n assert candidate(arr = [3, 1, 7, 11]) == False\n assert candidate(arr = [-10, -20, -30, -40, -50]) == True\n assert candidate(arr = [-10, -5, -3, -1, 2]) == True\n assert candidate(arr = [10, 5, 15, 20, 25]) == True\n assert candidate(arr = [1, -1, 2, -2, 4, -4, 8, -8, 16, -16]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8]) == True\n assert candidate(arr = [2, 1, 4, 2, 8, 4, 16]) == True\n assert candidate(arr = [1, 2, 3, 5, 6, 10, 20, 40]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == True\n assert candidate(arr = [-100, -50, -25, -12, -6, -3, -1, 0, 1, 2, 4]) == True\n assert candidate(arr = [4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -10, -20]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256]) == True\n assert candidate(arr = [0, 0, 0, 0]) == True\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1]) == True\n assert candidate(arr = [101, 202, 50, 25, 12, 6, 3]) == True\n assert candidate(arr = [1000, 501, 250, 125, 62, 31, 15, 7, 3, 1]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 60]) == True\n assert candidate(arr = [-1, 2, -3, 6, -4, 8]) == False\n assert candidate(arr = [-10, -20, 5, 3, 15]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 250, 125]) == True\n assert candidate(arr = [-1, -2, -3, -6, -12]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 0, 2, 0, 4, 0, 8, 0]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200]) == True\n assert candidate(arr = [3, 6, 9, 18, 27, 54, 81]) == True\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56]) == True\n assert candidate(arr = [1, 2, 3, 6, 9, 18, 36, 72]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5]) == True\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 50, 100]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == True\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == True\n assert candidate(arr = [1, 2, 3, 6, 12, 24, 48, 96, 192, 384]) == True\n assert candidate(arr = [-1, -2, -4, -8, -16]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == True\n assert candidate(arr = [0, 0, 1, 2, 4]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 38]) == True\n assert candidate(arr = [1, 2, 3, 5, 6, 10, 15, 20, 30, 60]) == True\n assert candidate(arr = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6]) == True\n assert candidate(arr = [-2, 2, -4, 4, -8, 8, -16, 16]) == True\n assert candidate(arr = [-10, -5, -15, -20, -25]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == True\n assert candidate(arr = [-1, 1, -2, 2, -4, 4, 8, -8]) == True\n assert candidate(arr = [0, 1, 2, 3, 6, 12, 24, 48, 96]) == True\n assert candidate(arr = [13, 26, 52, 104, 208, 416]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(arr = [-5, 10, -15, 20, -25, 50, -75]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 50, 75]) == True\n assert candidate(arr = [6, 12, 18, 24, 48]) == True\n assert candidate(arr = [1, 0, 2, 0, 4, 0, 8, 0, 16, 0]) == True\n assert candidate(arr = [1, 2, 3, 6, 12, 24, 48, 96]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 40]) == True\n assert candidate(arr = [-1, 2, -2, 4, -4, 8]) == True\n assert candidate(arr = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8]) == True\n assert candidate(arr = [15, 30, 45, 90, 135, 270]) == True\n assert candidate(arr = [-10, -5, -1, -2, -3, -4, -6, -8, -12, -16]) == True\n assert candidate(arr = [10, 20, 40, 80, 160, 320, 640]) == True\n assert candidate(arr = [-10, -5, 0, 5, 10]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50, -100, -200, -300]) == True\n assert candidate(arr = [-3, -6, -9, -12, -15, -18, -21, -24]) == True\n assert candidate(arr = [3, 6, 12, 24, 48, 96, 192, 384]) == True\n assert candidate(arr = [0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(arr = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == True\n assert candidate(arr = [-5, -10, -15, -20, -25, -30, -35, -40, -45]) == True\n assert candidate(arr = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 10]) == True\n assert candidate(arr = [11, 22, 44, 88, 176, 352, 704]) == True\n assert candidate(arr = [0, 0, 0, 0, 0]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24]) == True\n assert candidate(arr = [100, 51, 25, 12, 6, 3, 1]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 17, 19, 21]) == False\n assert candidate(arr = [0, 1, 2, 4, 8, 16, 32]) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 3, 9, 27, 81, 243, 729]) == False\n assert candidate(arr = [0, 1, 2, 3, 4, 8, 16]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 50, 100]) == True\n assert candidate(arr = [9, 18, 36, 72, 144, 288, 576]) == True\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 18, 36, 72]) == True\n assert candidate(arr = [7, 14, 28, 56, 112, 224, 448]) == True\n assert candidate(arr = [1, 2, 3, 6, 12, 24, 48, 96, 192, 384, 768]) == True\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1, 0]) == True\n assert candidate(arr = [1, 5, 10, 20, 25, 50, 100]) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(arr = [-2, -4, -6, -8, -16]) == True\n assert candidate(arr = [-10, -20, -30, -200, -300, -150]) == True\n assert candidate(arr = [0, 1, 2, 4, 8, 16, 32, 64]) == True\n assert candidate(arr = [1, 2, 3, 5, 6, 10, 15, 20, 30, 60, 120, 240]) == True\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1, 0, -1, -2, -4]) == True\n assert candidate(arr = [7, 14, 28, 56, 112, 224]) == True\n assert candidate(arr = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50]) == True\n assert candidate(arr = [7, 14, 28, 56, 112, 224, 448, 896]) == True\n assert candidate(arr = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 115]) == True\n assert candidate(arr = [10, 5, 15, 20, 2, 25, 50]) == True\n assert candidate(arr = [-2, -4, -1, -3, -5, -10]) == True\n assert candidate(arr = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == True\n assert candidate(arr = [-1, -2, -4, -8, -16, -32, -64]) == True\n assert candidate(arr = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32]) == True\n assert candidate(arr = [1, 2, 3, 6, 9, 18, 27, 54]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == True\n assert candidate(arr = [1, 0, 2, 0, 4, 0, 8, 0, 16, 0, 32, 0, 64, 0, 128, 0]) == True\n assert candidate(arr = [-2, -4, -8, -16, -32, -64, -128]) == True\n", "comparison": "exact"}, "public_tests": ["[10,2,5,3]", "[3,1,7,11]"], "hints": ["Loop from i = 0 to arr.length, maintaining in a hashTable the array elements from [0, i - 1].", "On each step of the loop check if we have seen the element 2 * arr[i] so far.", "Also check if we have seen arr[i] / 2 in case arr[i] % 2 == 0."], "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().checkIfExist", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:29+00:00", "tests_total": 147, "tests_dropped": 19, "flags": [], "topic_tags": ["array", "hash-table", "two-pointers", "binary-search", "sorting"]}, "language": "java", "interface": {"raw_signature": "public boolean checkIfExist(int[] arr) {", "container": "Solution", "callable": "checkIfExist", "parameters": [{"name": "arr", "type": "int[]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1347, "task_id": "minimum-number-of-steps-to-make-two-strings-anagram", "difficulty": "Medium", "problem_description": "You are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character.\n\nReturn the minimum number of steps to make t an anagram of s.\n\nAn Anagram of a string is a string that contains the same characters with a different (or the same) ordering.\n\nExample 1:\n\nInput: s = \"bab\", t = \"aba\"\nOutput: 1\nExplanation: Replace the first 'a' in t with b, t = \"bba\" which is anagram of s.\n\nExample 2:\n\nInput: s = \"leetcode\", t = \"practice\"\nOutput: 5\nExplanation: Replace 'p', 'r', 'a', 'i' and 'c' from t with proper characters to make t anagram of s.\n\nExample 3:\n\nInput: s = \"anagram\", t = \"mangaar\"\nOutput: 0\nExplanation: \"anagram\" and \"mangaar\" are anagrams.\n\nConstraints:\n\n- 1 <= s.length <= 5 * 10^4\n- s.length == t.length\n- s and t consist of lowercase English letters only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abacabadabacaba\",t = \"abcadbabacabaab\") == 1\n assert candidate(s = \"transform\",t = \"formartin\") == 1\n assert candidate(s = \"aabbcc\",t = \"ccbbaa\") == 0\n assert candidate(s = \"minimum\",t = \"numinum\") == 2\n assert candidate(s = \"hello\",t = \"bello\") == 1\n assert candidate(s = \"leetcode\",t = \"practice\") == 5\n assert candidate(s = \"aaabbb\",t = \"bbbaaa\") == 0\n assert candidate(s = \"transform\",t = \"formtrans\") == 0\n assert candidate(s = \"anagram\",t = \"mangaar\") == 0\n assert candidate(s = \"abcd\",t = \"dcba\") == 0\n assert candidate(s = \"bab\",t = \"aba\") == 1\n assert candidate(s = \"aaa\",t = \"bbb\") == 3\n assert candidate(s = \"abc\",t = \"def\") == 3\n assert candidate(s = \"abcde\",t = \"edcba\") == 0\n assert candidate(s = \"xyz\",t = \"zyx\") == 0\n assert candidate(s = \"optimization\",t = \"inipotizaton\") == 1\n assert candidate(s = \"pythonprogramming\",t = \"gnimmargorpnohtyp\") == 0\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",t = \"abcdefghijklmnopqrstuvwzyx\") == 0\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydog\",t = \"aquickbrownfoxjumpsoverthelazydog\") == 0\n assert candidate(s = \"bbaacc\",t = \"aabacc\") == 1\n assert candidate(s = \"aabbccddeeff\",t = \"fedcbafedcba\") == 0\n assert candidate(s = \"xylophone\",t = \"poloxynhe\") == 0\n assert candidate(s = \"strength\",t = \"grenstht\") == 0\n assert candidate(s = \"pythonprogramming\",t = \"prognimmargyphnot\") == 0\n assert candidate(s = \"algorithms\",t = \"logarithms\") == 0\n assert candidate(s = \"pythonprogramming\",t = \"programmingpython\") == 0\n assert candidate(s = \"longestword\",t = \"wordlongset\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxxwwvvuuttrrssqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 0\n assert candidate(s = \"mississippi\",t = \"ppissimisss\") == 1\n assert candidate(s = \"mississippi\",t = \"pississippi\") == 1\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\") == 0\n assert candidate(s = \"abracadabra\",t = \"arabracadab\") == 0\n assert candidate(s = \"permutations\",t = \"interpromust\") == 1\n assert candidate(s = \"aabbcceeddffee\",t = \"eeddffccbbbaaa\") == 2\n assert candidate(s = \"programmingisfun\",t = \"funprogrammingis\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 0\n assert candidate(s = \"elephant\",t = \"tehlanpe\") == 0\n assert candidate(s = \"elephant\",t = \"talehpen\") == 0\n assert candidate(s = \"permutations\",t = \"pertumations\") == 0\n assert candidate(s = \"synchronized\",t = \"chronizedsyn\") == 0\n assert candidate(s = \"thisisaverylongstring\",t = \"stringlongaverythisis\") == 0\n assert candidate(s = \"interstellar\",t = \"stellarestri\") == 1\n assert candidate(s = \"mississippi\",t = \"pisissmipis\") == 0\n assert candidate(s = \"mississippi\",t = \"psissimippi\") == 1\n assert candidate(s = \"amazingrace\",t = \"raceingazam\") == 0\n assert candidate(s = \"reducibility\",t = \"reducibility\") == 0\n assert candidate(s = \"recharacterization\",t = \"characterizationre\") == 0\n assert candidate(s = \"programming\",t = \"gimmnoprram\") == 1\n assert candidate(s = \"programming\",t = \"remmprogain\") == 1\n assert candidate(s = \"multimedia\",t = \"meediamult\") == 1\n assert candidate(s = \"xylophone\",t = \"phonexylo\") == 0\n assert candidate(s = \"mississippi\",t = \"ssissippiim\") == 0\n assert candidate(s = \"anagramanagram\",t = \"mangaarmangaar\") == 0\n assert candidate(s = \"congratulations\",t = \"congratulations\") == 0\n assert candidate(s = \"algorithm\",t = \"logarithm\") == 0\n assert candidate(s = \"racecar\",t = \"carrace\") == 0\n assert candidate(s = \"congratulations\",t = \"gratulationscon\") == 0\n assert candidate(s = \"optimization\",t = \"tionsimipazy\") == 2\n assert candidate(s = \"rhythm\",t = \"myrthh\") == 0\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",t = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"aabbccddeeff\",t = \"ffeeddccbbaa\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"unitedstates\",t = \"statedinutes\") == 0\n assert candidate(s = \"supercalifragilisticexpialidocious\",t = \"expialidocioussupercalifragilistic\") == 0\n assert candidate(s = \"abacabadabacabadabacabad\",t = \"bacdabcdabcdabcdabcdabcd\") == 6\n assert candidate(s = \"abacaxi\",t = \"xicabaa\") == 0\n assert candidate(s = \"programming\",t = \"gnimmargorp\") == 0\n assert candidate(s = \"mississippi\",t = \"ppiimississ\") == 0\n", "comparison": "exact"}, "public_tests": ["\"bab\"\n\"aba\"", "\"leetcode\"\n\"practice\"", "\"anagram\"\n\"mangaar\""], "hints": ["Count the frequency of characters of each string.", "Loop over all characters if the frequency of a character in t is less than the frequency of the same character in s then add the difference between the frequencies to the answer."], "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().minSteps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:31+00:00", "tests_total": 113, "tests_dropped": 44, "flags": [], "topic_tags": ["hash-table", "string", "counting"]}, "language": "java", "interface": {"raw_signature": "public int minSteps(String s, String t) {", "container": "Solution", "callable": "minSteps", "parameters": [{"name": "s", "type": "String"}, {"name": "t", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1349, "task_id": "maximum-students-taking-exam", "difficulty": "Hard", "problem_description": "Given a m * n matrix seats that represent seats distributions in a classroom. If a seat is broken, it is denoted by '#' character otherwise it is denoted by a '.' character.\n\nStudents can see the answers of those sitting next to the left, right, upper left and upper right, but he cannot see the answers of the student sitting directly in front or behind him. Return the maximum number of students that can take the exam together without any cheating being possible.\n\nStudents must be placed in seats in good condition.\n\nExample 1:\n\nInput: seats = [[\"#\",\".\",\"#\",\"#\",\".\",\"#\"],\n [\".\",\"#\",\"#\",\"#\",\"#\",\".\"],\n [\"#\",\".\",\"#\",\"#\",\".\",\"#\"]]\nOutput: 4\nExplanation: Teacher can place 4 students in available seats so they don't cheat on the exam.\n\nExample 2:\n\nInput: seats = [[\".\",\"#\"],\n [\"#\",\"#\"],\n [\"#\",\".\"],\n [\"#\",\"#\"],\n [\".\",\"#\"]]\nOutput: 3\nExplanation: Place all students in available seats.\n\nExample 3:\n\nInput: seats = [[\"#\",\".\",\".\",\".\",\"#\"],\n [\".\",\"#\",\".\",\"#\",\".\"],\n [\".\",\".\",\"#\",\".\",\".\"],\n [\".\",\"#\",\".\",\"#\",\".\"],\n [\"#\",\".\",\".\",\".\",\"#\"]]\nOutput: 10\nExplanation: Place students in available seats in column 1, 3 and 5.\n\nConstraints:\n\n- seats contains only characters '.' and'#'.\n- m == seats.length\n- n == seats[i].length\n- 1 <= m <= 8\n- 1 <= n <= 8\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#']]) == 10\n assert candidate(seats = [['#', '.', '#', '#', '.', '#'], ['.', '#', '#', '#', '#', '.'], ['#', '.', '#', '#', '.', '#']]) == 4\n assert candidate(seats = [['.', '.#'], ['#', '#'], ['#', '.'], ['#', '#'], ['.', '#']]) == 3\n assert candidate(seats = [['.', '#'], ['#', '#'], ['#', '.'], ['#', '#'], ['.', '#']]) == 3\n assert candidate(seats = [['#', '.', '#', '#', '.', '#'], ['.', '#', '#', '#', '#', '.'], ['#', '.', '#', '#', '.', '#']]) == 4\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#']]) == 10\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#']]) == 10\n assert candidate(seats = [['.', '#'], ['#', '#'], ['#', '.'], ['#', '#'], ['.', '#']]) == 3\n assert candidate(seats = [['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 23\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 15\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 32\n assert candidate(seats = [['.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '#', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 31\n assert candidate(seats = [['.', '.', '#'], ['.', '#', '.'], ['#', '.', '.'], ['.', '.', '#'], ['.', '#', '.'], ['#', '.', '.']]) == 8\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['#', '.', '#', '.', '.', '#']]) == 16\n assert candidate(seats = [['.', '.', '.', '#'], ['.', '#', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '#', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '#']]) == 15\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['#', '.', '.', '.', '#']]) == 9\n assert candidate(seats = [['#', '.', '#', '#', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 30\n assert candidate(seats = [['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.']]) == 9\n assert candidate(seats = [['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#']]) == 9\n assert candidate(seats = [['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.']]) == 11\n assert candidate(seats = [['.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.']]) == 23\n assert candidate(seats = [['.', '#', '.', '.', '#', '.', '#'], ['#', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['#', '.', '.', '.', '.', '.', '#']]) == 16\n assert candidate(seats = [['.', '.', '#', '#', '.', '.', '#'], ['#', '.', '.', '.', '#', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '#']]) == 12\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 14\n assert candidate(seats = [['.', '#', '.', '#', '.', '#'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '.']]) == 15\n assert candidate(seats = [['.', '.', '.', '#', '.'], ['#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#'], ['.', '.', '.', '#', '.']]) == 9\n assert candidate(seats = [['.', '#', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 24\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.']]) == 21\n assert candidate(seats = [['#', '.', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '.', '#'], ['.', '#', '.', '#', '.', '#', '.', '.'], ['#', '.', '#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#', '.', '#']]) == 19\n assert candidate(seats = [['#', '.', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '.', '#'], ['.', '#', '.', '#', '.', '#', '.', '.'], ['#', '.', '.', '.', '.', '.', '#', '.'], ['.', '#', '#', '.', '#', '.', '.', '#'], ['#', '.', '.', '#', '.', '.', '#', '.'], ['.', '#', '.', '.', '#', '#', '.', '#']]) == 20\n assert candidate(seats = [['#', '#', '.', '.', '#'], ['.', '.', '.', '.', '.'], ['#', '.', '.', '.', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '.', '.', '#'], ['.', '.', '.', '.', '.']]) == 12\n assert candidate(seats = [['#', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#']]) == 0\n assert candidate(seats = [['.', '.', '#', '.', '#', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '#', '.', '.', '#'], ['.', '.', '#', '.', '.', '#', '.', '.'], ['#', '.', '.', '.', '#', '.', '.', '#'], ['.', '#', '.', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '#', '.', '.', '.']]) == 23\n assert candidate(seats = [['.', '.', '#', '.', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.']]) == 16\n assert candidate(seats = [['.', '.', '#', '.', '.', '#'], ['.', '#', '.', '#', '.', '.'], ['#', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '.', '#'], ['#', '.', '#', '.', '.', '.'], ['.', '.', '.', '#', '.', '#']]) == 13\n assert candidate(seats = [['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 18\n assert candidate(seats = [['#', '#', '.', '#', '#', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 28\n assert candidate(seats = [['#', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['.', '.', '#', '#', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['#', '.', '.', '.', '.', '#', '.']]) == 15\n assert candidate(seats = [['.', '.', '#', '#', '.', '.'], ['#', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['#', '.', '#', '.', '.', '#']]) == 14\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '#', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '#', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 22\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['#', '#', '.', '#', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '#', '#', '#', '.'], ['.', '.', '.', '.', '.', '.']]) == 13\n assert candidate(seats = [['#', '.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.', '#']]) == 28\n assert candidate(seats = [['.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 18\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.']]) == 28\n assert candidate(seats = [['.', '.', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 32\n assert candidate(seats = [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.']]) == 15\n assert candidate(seats = [['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#']]) == 6\n assert candidate(seats = [['#', '.', '.', '.', '.', '#'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '#', '.', '.', '#', '.'], ['#', '.', '.', '.', '.', '#']]) == 11\n assert candidate(seats = [['.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.']]) == 13\n assert candidate(seats = [['.', '#', '.', '.', '#', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '#', '.', '.', '#'], ['.', '#', '.', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '#', '.', '.', '.']]) == 24\n assert candidate(seats = [['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#']]) == 12\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 12\n assert candidate(seats = [['#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.'], ['#', '.', '#', '.', '.', '#']]) == 16\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '#', '.', '.', '.'], ['.', '.', '#', '.', '#', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.']]) == 24\n assert candidate(seats = [['.', '.', '.', '#', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 32\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.'], ['#', '.', '.', '.', '#']]) == 10\n assert candidate(seats = [['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#']]) == 9\n assert candidate(seats = [['.', '.', '.', '#'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.']]) == 11\n assert candidate(seats = [['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '#']]) == 29\n assert candidate(seats = [['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.']]) == 9\n assert candidate(seats = [['#', '.', '.', '#'], ['.', '.', '.', '.'], ['#', '.', '.', '#'], ['.', '.', '.', '.'], ['#', '.', '.', '#']]) == 7\n assert candidate(seats = [['#', '.', '.', '#', '.', '#'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.'], ['#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 13\n assert candidate(seats = [['#', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['#', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '#']]) == 20\n assert candidate(seats = [['.', '#', '.', '.', '#', '.'], ['#', '.', '#', '.', '.', '#'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '#', '.', '.', '#'], ['.', '#', '.', '.', '#', '.']]) == 12\n assert candidate(seats = [['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.']]) == 9\n assert candidate(seats = [['.', '.', '.', '.', '.', '#', '.'], ['#', '.', '#', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '#'], ['.', '.', '.', '.', '.', '#', '.']]) == 15\n", "comparison": "exact"}, "public_tests": ["[[\"#\",\".\",\"#\",\"#\",\".\",\"#\"],[\".\",\"#\",\"#\",\"#\",\"#\",\".\"],[\"#\",\".\",\"#\",\"#\",\".\",\"#\"]]", "[[\".\",\"#\"],[\"#\",\"#\"],[\"#\",\".\"],[\"#\",\"#\"],[\".\",\"#\"]]", "[[\"#\",\".\",\".\",\".\",\"#\"],[\".\",\"#\",\".\",\"#\",\".\"],[\".\",\".\",\"#\",\".\",\".\"],[\".\",\"#\",\".\",\"#\",\".\"],[\"#\",\".\",\".\",\".\",\"#\"]]"], "hints": ["Students in row i only can see exams in row i+1.", "Use Dynamic programming to compute the result given a (current row, bitmask people seated in previous row)."], "metadata": {"canonical_parameter_names": ["seats"], "leetcode_dataset_entry_point": "Solution().maxStudents", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:33+00:00", "tests_total": 66, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "bit-manipulation", "matrix", "bitmask", "maximum-flow", "maximum-matching", "bipartite-graph", "edmonds-karp-algorithm", "mpm-algorithm", "push-relabel-algorithm", "minimum-cut", "matching-graph", "flow-network", "dinics-algorithm"]}, "language": "java", "interface": {"raw_signature": "public int maxStudents(char[][] seats) {", "container": "Solution", "callable": "maxStudents", "parameters": [{"name": "seats", "type": "char[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1351, "task_id": "count-negative-numbers-in-a-sorted-matrix", "difficulty": "Easy", "problem_description": "Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid.\n\nExample 1:\n\nInput: grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]\nOutput: 8\nExplanation: There are 8 negatives number in the matrix.\n\nExample 2:\n\nInput: grid = [[3,2],[1,0]]\nOutput: 0\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 100\n- -100 <= grid[i][j] <= 100\n\nFollow up: Could you find an O(n + m) solution?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[-1, -1], [-1, -1]]) == 4\n assert candidate(grid = [[-3], [-2], [-1], [0], [1]]) == 0\n assert candidate(grid = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]) == 12\n assert candidate(grid = [[-1, -1, -1], [-5, -5, -5]]) == 6\n assert candidate(grid = [[3, 2], [1, 0]]) == 0\n assert candidate(grid = [[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [-1, -1, -2, -3]]) == 8\n assert candidate(grid = [[1, -1], [-1, -1]]) == 3\n assert candidate(grid = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]) == 16\n assert candidate(grid = [[5, 2, 1], [4, 3, 1], [3, 2, 1]]) == 0\n assert candidate(grid = [[1, 2, 3], [4, 5, 6]]) == 0\n assert candidate(grid = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]) == 12\n assert candidate(grid = [[100, 90, 80, -10], [-9, -8, -7, -6], [-5, -4, -3, -2], [-4, -3, -2, -1]]) == 13\n assert candidate(grid = [[1]]) == 0\n assert candidate(grid = [[-5]]) == 1\n assert candidate(grid = [[1, 2, 3], [0, -1, -2], [-3, -4, -5]]) == 5\n assert candidate(grid = [[-1]]) == 1\n assert candidate(grid = [[5, 4, 3, 2, 1], [4, 3, 2, 1, 0], [3, 2, 1, 0, -1], [2, 1, 0, -1, -2], [1, 0, -1, -2, -3]]) == 6\n assert candidate(grid = [[-1, 0], [0, -1]]) == 1\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) == 0\n assert candidate(grid = [[-1, 2, -3, 4, -5], [6, -7, 8, -9, 10], [-11, 12, -13, 14, -15], [16, -17, 18, -19, 20]]) == 10\n assert candidate(grid = [[1, 0, 0, 0, 0], [-1, 0, 0, 0, 0], [-1, -1, 0, 0, 0], [-1, -1, -1, 0, 0], [-1, -1, -1, -1, 0]]) == 20\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, -1]]) == 1\n assert candidate(grid = [[-100, -99, -98, -97, -96], [-95, -94, -93, -92, -91], [-90, -89, -88, -87, -86], [-85, -84, -83, -82, -81], [-80, -79, -78, -77, -76]]) == 25\n assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 7, 6, 5, 4, 3, 2, 1, 0, -1], [7, 6, 5, 4, 3, 2, 1, 0, -1, -2], [6, 5, 4, 3, 2, 1, 0, -1, -2, -3], [5, 4, 3, 2, 1, 0, -1, -2, -3, -4], [4, 3, 2, 1, 0, -1, -2, -3, -4, -5], [3, 2, 1, 0, -1, -2, -3, -4, -5, -6], [2, 1, 0, -1, -2, -3, -4, -5, -6, -7], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8]]) == 36\n assert candidate(grid = [[-99, -98, -97, -96, -95, -94, -93, -92, -91, -90], [-89, -88, -87, -86, -85, -84, -83, -82, -81, -80], [-79, -78, -77, -76, -75, -74, -73, -72, -71, -70], [-69, -68, -67, -66, -65, -64, -63, -62, -61, -60], [-59, -58, -57, -56, -55, -54, -53, -52, -51, -50], [-49, -48, -47, -46, -45, -44, -43, -42, -41, -40], [-39, -38, -37, -36, -35, -34, -33, -32, -31, -30], [-29, -28, -27, -26, -25, -24, -23, -22, -21, -20], [-19, -18, -17, -16, -15, -14, -13, -12, -11, -10], [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0]]) == 100\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-2, -2, -2, -2, -2, -2, -2, -2, -2, -2], [-3, -3, -3, -3, -3, -3, -3, -3, -3, -3]]) == 30\n assert candidate(grid = [[1, 1, 1, -1, -1, -1], [1, 1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1]]) == 13\n assert candidate(grid = [[9, -9, 8, -8], [7, -7, 6, -6], [5, -5, 4, -4], [3, -3, 2, -2], [1, -1, 0, -1]]) == 15\n assert candidate(grid = [[99, 98, 97, 96, 95, 94], [93, 92, 91, 90, -1, -2], [-3, -4, -5, -6, -7, -8], [-9, -10, -11, -12, -13, -14]]) == 14\n assert candidate(grid = [[10, -10, 20, -20, 30, -30], [9, -9, 18, -18, 27, -27], [8, -8, 16, -16, 24, -24], [7, -7, 14, -14, 21, -21]]) == 20\n assert candidate(grid = [[0, 0, 0, 0, -1], [0, 0, -1, -1, -1], [0, -1, -1, -1, -1], [-1, -1, -1, -1, -1]]) == 13\n assert candidate(grid = [[-5, -4, -3, -2, -1], [0, 0, 0, 0, 0], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == 20\n assert candidate(grid = [[1, 0, -1, 0, -1], [0, -1, 0, -1, 0], [-1, 0, -1, 0, -1], [0, -1, 0, -1, 0], [-1, 0, -1, 0, -1]]) == 15\n assert candidate(grid = [[-50, -40, -30, -20, -10], [30, 20, 10, 0, -10], [-20, -10, 0, 10, 20], [10, 0, 10, 20, 30], [0, 10, 20, 30, 40]]) == 0\n assert candidate(grid = [[90, 80, 70, 60, 50, 40, 30, 20, 10, 0], [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]]) == 10\n assert candidate(grid = [[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[-5, -4, -3, -2, -1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[-1, -1, -1, 0], [1, 0, -1, -1], [1, -1, -1, -1], [-1, -1, -1, -1]]) == 11\n assert candidate(grid = [[-3, -2, -1, 0], [2, 1, 0, -1], [1, 0, -1, -2], [0, -1, -2, -3]]) == 6\n assert candidate(grid = [[10, -5, 3, 2, -1], [-3, 0, -1, 0, -4], [-5, -6, -7, -8, -9]]) == 14\n assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 7, 6, 5, 4, 3, 2, 1, 0, -1], [7, 6, 5, 4, 3, 2, 1, 0, -1, -2], [6, 5, 4, 3, 2, 1, 0, -1, -2, -3], [5, 4, 3, 2, 1, 0, -1, -2, -3, -4], [4, 3, 2, 1, 0, -1, -2, -3, -4, -5], [3, 2, 1, 0, -1, -2, -3, -4, -5, -6], [2, 1, 0, -1, -2, -3, -4, -5, -6, -7], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8]]) == 36\n assert candidate(grid = [[-100, -99, -98, -97, -96], [0, 0, 0, -1, -2], [-3, -4, -5, -6, -7], [-8, -9, -10, -11, -12]]) == 14\n assert candidate(grid = [[1, -1, -2, -3], [-1, -2, -3, -4], [-2, -3, -4, -5], [-3, -4, -5, -6]]) == 15\n assert candidate(grid = [[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], [-2, -3, -4, -5, -6, -7, -8, -9, -10, -11], [-3, -4, -5, -6, -7, -8, -9, -10, -11, -12]]) == 30\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, -1], [0, 0, 0, 0, 0, 0, 0, 0, -1, -1], [0, 0, 0, 0, 0, 0, 0, -1, -1, -1], [0, 0, 0, 0, 0, 0, -1, -1, -1, -1], [0, 0, 0, 0, 0, -1, -1, -1, -1, -1], [0, 0, 0, 0, -1, -1, -1, -1, -1, -1], [0, 0, 0, -1, -1, -1, -1, -1, -1, -1], [0, 0, -1, -1, -1, -1, -1, -1, -1, -1], [0, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == 45\n assert candidate(grid = [[-1, 0, 1, 2, 3], [0, -1, -2, -3, -4], [-1, -2, -3, -4, -5], [-10, -20, -30, -40, -50]]) == 14\n assert candidate(grid = [[10, -10, 20, -20], [5, -5, 15, -15], [0, 0, 0, 0], [-1, -2, -3, -4]]) == 4\n assert candidate(grid = [[99, 98, 97, 96, 95, 94, 93, 92, 91, 90], [89, 88, 87, 86, 85, 84, 83, 82, 81, 80], [79, 78, 77, 76, 75, 74, 73, 72, 71, 70], [69, 68, 67, 66, 65, 64, 63, 62, 61, 60], [59, 58, 57, 56, 55, 54, 53, 52, 51, 50], [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], [-11, -12, -13, -14, -15, -16, -17, -18, -19, -20], [-21, -22, -23, -24, -25, -26, -27, -28, -29, -30], [-31, -32, -33, -34, -35, -36, -37, -38, -39, -40], [-41, -42, -43, -44, -45, -46, -47, -48, -49, -50]]) == 50\n assert candidate(grid = [[-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1]]) == 15\n assert candidate(grid = [[2, 1, 0, -1, -2], [1, 0, -1, -2, -3], [0, -1, -2, -3, -4], [-1, -2, -3, -4, -5], [-2, -3, -4, -5, -6]]) == 19\n assert candidate(grid = [[100, 90, 80, 70, 60, 50, 40, 30, 20, 10], [90, 80, 70, 60, 50, 40, 30, 20, 10, 0], [80, 70, 60, 50, 40, 30, 20, 10, 0, -10], [70, 60, 50, 40, 30, 20, 10, 0, -10, -20], [60, 50, 40, 30, 20, 10, 0, -10, -20, -30]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[-1, -2, -3, -4], [-5, -6, -7, -8], [-9, -10, -11, -12], [-13, -14, -15, -16]]) == 16\n assert candidate(grid = [[-1, -2, -3, -4, -5], [-6, -7, -8, -9, -10], [-11, -12, -13, -14, -15], [-16, -17, -18, -19, -20]]) == 20\n assert candidate(grid = [[1, -1, 0, 0], [-1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[5, 4, 3, 2, 1], [4, 3, 2, 1, 0], [3, 2, 1, -1, -2], [2, 1, -2, -3, -4], [1, 0, -3, -4, -5]]) == 8\n assert candidate(grid = [[10, -5, -4, -3], [-7, -6, -5, -4], [-8, -7, -6, -5], [-9, -8, -7, -6]]) == 15\n assert candidate(grid = [[50, 40, 30, 20, 10], [45, 35, 25, 15, 5], [40, 30, 20, 10, 0], [35, 25, 15, 5, -5]]) == 1\n assert candidate(grid = [[-1, -2, -3, -4, -5], [-2, -3, -4, -5, -6], [-3, -4, -5, -6, -7], [-4, -5, -6, -7, -8], [-5, -6, -7, -8, -9]]) == 25\n assert candidate(grid = [[1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]]) == 90\n assert candidate(grid = [[0, 0, 0, 0, -1], [0, 0, 0, -1, -2], [0, 0, -1, -2, -3], [0, -1, -2, -3, -4], [-1, -2, -3, -4, -5]]) == 15\n assert candidate(grid = [[-100, -99, -98, -97, -96, -95, -94, -93, -92, -91], [-90, -89, -88, -87, -86, -85, -84, -83, -82, -81], [-80, -79, -78, -77, -76, -75, -74, -73, -72, -71], [-70, -69, -68, -67, -66, -65, -64, -63, -62, -61], [-60, -59, -58, -57, -56, -55, -54, -53, -52, -51], [-50, -49, -48, -47, -46, -45, -44, -43, -42, -41], [-40, -39, -38, -37, -36, -35, -34, -33, -32, -31], [-30, -29, -28, -27, -26, -25, -24, -23, -22, -21], [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11], [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]]) == 100\n assert candidate(grid = [[-5, -4, -3, -2, -1], [-10, -9, -8, -7, -6], [-15, -14, -13, -12, -11], [-20, -19, -18, -17, -16], [-25, -24, -23, -22, -21]]) == 25\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, -1, -2], [0, -1, -2, -3], [-1, -2, -3, -4]]) == 9\n assert candidate(grid = [[1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1]]) == 20\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, -1], [0, 0, -1, -1], [0, -1, -1, -1]]) == 6\n assert candidate(grid = [[50, 40, 30, 20, 10], [45, 35, 25, 15, 5], [40, 30, 20, 10, 0], [35, 25, 15, 5, -5], [30, 20, 10, 0, -10]]) == 2\n assert candidate(grid = [[10, 8, 6, 4, 2, 0, -2, -4], [-6, -8, -10, -12, -14, -16, -18, -20], [-10, -12, -14, -16, -18, -20, -22, -24]]) == 18\n assert candidate(grid = [[-10, -20, -30, -40], [-20, -30, -40, -50], [-30, -40, -50, -60], [-40, -50, -60, -70]]) == 16\n assert candidate(grid = [[-100, -99, -98, -97], [-96, -95, -94, -93], [-92, -91, -90, -89], [-88, -87, -86, -85]]) == 16\n assert candidate(grid = [[10, 20, 30, 40, 50], [20, 30, 40, 50, 60], [30, 40, 50, 60, 70], [40, 50, 60, 70, 80], [50, 60, 70, 80, 90]]) == 0\n assert candidate(grid = [[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 0\n assert candidate(grid = [[-100, -99, -98, -97, -96, -95, -94, -93, -92, -91], [-90, -89, -88, -87, -86, -85, -84, -83, -82, -81], [-80, -79, -78, -77, -76, -75, -74, -73, -72, -71], [-70, -69, -68, -67, -66, -65, -64, -63, -62, -61]]) == 40\n assert candidate(grid = [[-50, -49, -48, -47, -46, -45], [-44, -43, -42, -41, -40, -39], [-38, -37, -36, -35, -34, -33], [-32, -31, -30, -29, -28, -27]]) == 24\n assert candidate(grid = [[-100, -99, -98], [-99, -98, -97], [-98, -97, -96], [-97, -96, -95]]) == 12\n assert candidate(grid = [[10, 5, 0, -10, -20], [-5, -15, -20, -25, -30], [-1, -2, -3, -4, -5]]) == 12\n assert candidate(grid = [[1, -1, 0], [1, -1, 0], [1, -1, 0]]) == 6\n assert candidate(grid = [[1, 0, -1], [-1, -2, -3], [-2, -3, -4], [-3, -4, -5]]) == 10\n assert candidate(grid = [[9, 7, 5, 3, 1], [-1, -3, -5, -7, -9], [-2, -4, -6, -8, -10], [-3, -6, -9, -12, -15]]) == 15\n assert candidate(grid = [[0, 0, 0], [0, 0, -1], [0, -1, -2], [-1, -2, -3]]) == 6\n assert candidate(grid = [[5, 4, 3, 2, 1], [4, 3, 2, 1, -1], [3, 2, 1, -1, -2], [2, 1, -1, -2, -3], [1, -1, -2, -3, -4]]) == 10\n assert candidate(grid = [[1, 0, -1], [-1, 0, 1], [0, 1, -1]]) == 1\n assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, -1], [8, 7, 6, 5, 4, 3, 2, 1, -2, -3], [7, 6, 5, 4, 3, 2, 1, -3, -4, -5]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, -1, -1], [0, 0, 0, -1, -1, -2], [-1, -1, -2, -3, -4, -5]]) == 11\n assert candidate(grid = [[-2, -1, 0, 1, 2], [3, 4, 5, 6, 7], [8, 9, 10, 11, 12], [-13, -14, -15, -16, -17], [-18, -19, -20, -21, -22]]) == 10\n assert candidate(grid = [[1, -1, 2, -2, 3, -3, 4, -4], [1, -1, 2, -2, 3, -3, 4, -4], [1, -1, 2, -2, 3, -3, 4, -4], [1, -1, 2, -2, 3, -3, 4, -4]]) == 28\n assert candidate(grid = [[5, 4, 3, 2, 1, 0, -1, -2, -3, -4], [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]]) == 9\n assert candidate(grid = [[5, 4, 3, 2, 1], [-1, -2, -3, -4, -5], [-6, -7, -8, -9, -10]]) == 10\n assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, -1], [8, 7, 6, 5, 4, 3, 2, 1, -1, -2], [7, 6, 5, 4, 3, 2, 1, -1, -2, -3], [6, 5, 4, 3, 2, 1, -1, -2, -3, -4], [5, 4, 3, 2, 1, -1, -2, -3, -4, -5], [4, 3, 2, 1, -1, -2, -3, -4, -5, -6], [3, 2, 1, -1, -2, -3, -4, -5, -6, -7], [2, 1, -1, -2, -3, -4, -5, -6, -7, -8], [1, -1, -2, -3, -4, -5, -6, -7, -8, -9]]) == 45\n assert candidate(grid = [[100, -50, 0], [90, -40, 0], [80, -30, 0], [70, -20, 0], [60, -10, 0]]) == 10\n", "comparison": "exact"}, "public_tests": ["[[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]", "[[3,2],[1,0]]"], "hints": ["Use binary search for optimization or simply brute force."], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().countNegatives", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:17:36+00:00", "tests_total": 96, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "binary-search", "matrix"]}, "language": "java", "interface": {"raw_signature": "public int countNegatives(int[][] grid) {", "container": "Solution", "callable": "countNegatives", "parameters": [{"name": "grid", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} @@ -444,7 +444,7 @@ {"question_id": 1450, "task_id": "number-of-students-doing-homework-at-a-given-time", "difficulty": "Easy", "problem_description": "Given two integer arrays startTime and endTime and given an integer queryTime.\n\nThe ith student started doing their homework at the time startTime[i] and finished it at time endTime[i].\n\nReturn the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime lays in the interval [startTime[i], endTime[i]] inclusive.\n\nExample 1:\n\nInput: startTime = [1,2,3], endTime = [3,2,7], queryTime = 4\nOutput: 1\nExplanation: We have 3 students where:\nThe first student started doing homework at time 1 and finished at time 3 and wasn't doing anything at time 4.\nThe second student started doing homework at time 2 and finished at time 2 and also wasn't doing anything at time 4.\nThe third student started doing homework at time 3 and finished at time 7 and was the only student doing homework at time 4.\n\nExample 2:\n\nInput: startTime = [4], endTime = [4], queryTime = 4\nOutput: 1\nExplanation: The only student was doing their homework at the queryTime.\n\nConstraints:\n\n- startTime.length == endTime.length\n- 1 <= startTime.length <= 100\n- 1 <= startTime[i] <= endTime[i] <= 1000\n- 1 <= queryTime <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(startTime = [9, 8, 7, 6],endTime = [10, 9, 8, 7],queryTime = 8) == 2\n assert candidate(startTime = [5, 5, 5, 5],endTime = [10, 10, 10, 10],queryTime = 7) == 4\n assert candidate(startTime = [9, 8, 7, 6, 5, 4, 3, 2, 1],endTime = [10, 9, 8, 7, 6, 5, 4, 3, 2],queryTime = 5) == 2\n assert candidate(startTime = [4],endTime = [4],queryTime = 4) == 1\n assert candidate(startTime = [1, 2, 3],endTime = [3, 2, 7],queryTime = 4) == 1\n assert candidate(startTime = [100, 200, 300],endTime = [150, 250, 350],queryTime = 225) == 1\n assert candidate(startTime = [1, 3, 6, 7, 9],endTime = [2, 5, 8, 10, 12],queryTime = 6) == 1\n assert candidate(startTime = [9, 8, 7, 6, 5, 4, 3, 2, 1],endTime = [10, 9, 8, 7, 6, 5, 4, 3, 2],queryTime = 6) == 2\n assert candidate(startTime = [1, 1, 1, 1],endTime = [2, 2, 2, 2],queryTime = 1) == 4\n assert candidate(startTime = [1, 3, 5, 7],endTime = [2, 4, 6, 8],queryTime = 5) == 1\n assert candidate(startTime = [10, 20, 30],endTime = [15, 25, 35],queryTime = 22) == 1\n assert candidate(startTime = [5, 5, 5, 5],endTime = [6, 6, 6, 6],queryTime = 5) == 4\n assert candidate(startTime = [100, 200, 300],endTime = [150, 250, 350],queryTime = 225) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1],endTime = [2, 2, 2, 2, 2],queryTime = 1) == 5\n assert candidate(startTime = [100, 200, 300, 400],endTime = [199, 299, 399, 499],queryTime = 250) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queryTime = 500) == 6\n assert candidate(startTime = [500, 550, 600, 650, 700, 750, 800, 850, 900, 950],endTime = [550, 600, 650, 700, 750, 800, 850, 900, 950, 1000],queryTime = 725) == 1\n assert candidate(startTime = [10, 15, 20, 25, 30, 35, 40, 45, 50],endTime = [14, 19, 24, 29, 34, 39, 44, 49, 54],queryTime = 22) == 1\n assert candidate(startTime = [50, 100, 150, 200, 250],endTime = [75, 125, 175, 225, 275],queryTime = 100) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1, 1],endTime = [10, 20, 30, 40, 50, 60],queryTime = 5) == 6\n assert candidate(startTime = [250, 500, 750],endTime = [260, 510, 760],queryTime = 255) == 1\n assert candidate(startTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],endTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queryTime = 55) == 5\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [19, 29, 39, 49, 59, 69, 79, 89, 99, 109],queryTime = 55) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50],endTime = [15, 25, 35, 45, 55],queryTime = 28) == 0\n assert candidate(startTime = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],endTime = [55, 105, 155, 205, 255, 305, 355, 405, 455, 505],queryTime = 102) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1],endTime = [5, 5, 5, 5, 5],queryTime = 3) == 5\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queryTime = 10) == 1\n assert candidate(startTime = [1, 10, 20, 30, 40, 50],endTime = [10, 20, 30, 40, 50, 60],queryTime = 55) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50],endTime = [15, 25, 35, 45, 55],queryTime = 33) == 1\n assert candidate(startTime = [300, 300, 300, 300],endTime = [600, 600, 600, 600],queryTime = 400) == 4\n assert candidate(startTime = [10, 20, 30, 40, 50],endTime = [10, 20, 30, 40, 50],queryTime = 10) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [10, 11, 12, 13, 14],queryTime = 8) == 5\n assert candidate(startTime = [1, 1, 1, 1, 1, 1],endTime = [6, 7, 8, 9, 10, 11],queryTime = 5) == 6\n assert candidate(startTime = [1, 1, 1, 1],endTime = [1000, 1000, 1000, 1000],queryTime = 500) == 4\n assert candidate(startTime = [5, 10, 15, 20, 25],endTime = [14, 19, 24, 29, 34],queryTime = 22) == 2\n assert candidate(startTime = [100, 200, 300, 400],endTime = [150, 250, 350, 450],queryTime = 225) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [10, 20, 30, 40, 50],queryTime = 1) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [150, 250, 350, 450, 550],queryTime = 225) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],endTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queryTime = 5) == 10\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],queryTime = 10) == 2\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [100, 200, 300, 400, 500],queryTime = 100) == 1\n assert candidate(startTime = [10, 20, 30, 40],endTime = [100, 200, 300, 400],queryTime = 150) == 3\n assert candidate(startTime = [900, 905, 910, 915],endTime = [909, 914, 919, 924],queryTime = 907) == 2\n assert candidate(startTime = [1, 3, 6, 8, 10],endTime = [2, 5, 7, 10, 12],queryTime = 4) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1],endTime = [1, 1, 1, 1, 1],queryTime = 1) == 5\n assert candidate(startTime = [2, 2, 2, 2, 2],endTime = [10, 10, 10, 10, 10],queryTime = 6) == 5\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [200, 300, 400, 500, 600],queryTime = 350) == 1\n assert candidate(startTime = [1, 3, 5, 7, 9],endTime = [2, 4, 6, 8, 10],queryTime = 5) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [150, 250, 350, 450, 550],queryTime = 275) == 0\n assert candidate(startTime = [100, 200, 300, 400],endTime = [101, 201, 301, 401],queryTime = 200) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],queryTime = 63) == 1\n assert candidate(startTime = [100, 150, 200, 250],endTime = [149, 199, 249, 299],queryTime = 175) == 1\n assert candidate(startTime = [50, 100, 150, 200, 250],endTime = [99, 199, 299, 399, 499],queryTime = 100) == 1\n assert candidate(startTime = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],endTime = [14, 24, 34, 44, 54, 64, 74, 84, 94, 104],queryTime = 100) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],endTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queryTime = 50) == 6\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],endTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queryTime = 10) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queryTime = 5) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [10, 9, 8, 7, 6],queryTime = 6) == 5\n assert candidate(startTime = [200, 200, 300, 300],endTime = [200, 400, 400, 500],queryTime = 200) == 2\n assert candidate(startTime = [10, 10, 10, 10, 10],endTime = [15, 15, 15, 15, 15],queryTime = 12) == 5\n assert candidate(startTime = [1, 10, 20, 30, 40, 50],endTime = [10, 20, 30, 40, 50, 60],queryTime = 25) == 1\n assert candidate(startTime = [999, 998, 997, 996, 995],endTime = [1000, 1000, 1000, 1000, 1000],queryTime = 999) == 5\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [150, 250, 350, 450, 550],queryTime = 325) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1],endTime = [1000, 1000, 1000, 1000, 1000],queryTime = 500) == 5\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [200, 300, 400, 500, 600],queryTime = 250) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [5, 10, 15, 20, 25],queryTime = 3) == 3\n assert candidate(startTime = [9, 10, 11, 12, 13],endTime = [10, 12, 14, 16, 18],queryTime = 12) == 3\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [10, 20, 30, 40, 50],queryTime = 25) == 3\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [199, 299, 399, 499, 599],queryTime = 450) == 1\n assert candidate(startTime = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29],endTime = [4, 7, 10, 13, 16, 19, 22, 25, 28, 31],queryTime = 15) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],queryTime = 55) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50],endTime = [100, 110, 120, 130, 140],queryTime = 60) == 5\n assert candidate(startTime = [1, 3, 5, 7, 9, 11],endTime = [2, 4, 6, 8, 10, 12],queryTime = 6) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [150, 250, 350, 450, 550],queryTime = 400) == 1\n assert candidate(startTime = [500, 501, 502, 503, 504, 505],endTime = [500, 501, 502, 503, 504, 505],queryTime = 505) == 1\n assert candidate(startTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],endTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queryTime = 7) == 10\n assert candidate(startTime = [500, 600, 700, 800],endTime = [599, 699, 799, 899],queryTime = 750) == 1\n assert candidate(startTime = [1, 100, 200, 300, 400],endTime = [100, 200, 300, 400, 500],queryTime = 150) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queryTime = 15) == 6\n assert candidate(startTime = [500, 550, 600, 650],endTime = [501, 551, 601, 651],queryTime = 550) == 1\n assert candidate(startTime = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],endTime = [5, 6, 6, 7, 7, 8, 8, 9, 9, 10],queryTime = 6) == 9\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [1000, 1000, 1000, 1000, 1000],queryTime = 500) == 5\n assert candidate(startTime = [10, 20, 30, 40],endTime = [15, 25, 35, 45],queryTime = 22) == 1\n", "comparison": "exact"}, "public_tests": ["[1,2,3]\n[3,2,7]\n4", "[4]\n[4]\n4"], "hints": ["Imagine that startTime[i] and endTime[i] form an interval (i.e. [startTime[i], endTime[i]]).", "The answer is how many times the queryTime laid in those mentioned intervals."], "metadata": {"canonical_parameter_names": ["startTime", "endTime", "queryTime"], "leetcode_dataset_entry_point": "Solution().busyStudent", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:32+00:00", "tests_total": 95, "tests_dropped": 12, "flags": [], "topic_tags": ["array"]}, "language": "java", "interface": {"raw_signature": "public int busyStudent(int[] startTime, int[] endTime, int queryTime) {", "container": "Solution", "callable": "busyStudent", "parameters": [{"name": "startTime", "type": "int[]"}, {"name": "endTime", "type": "int[]"}, {"name": "queryTime", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1451, "task_id": "rearrange-words-in-a-sentence", "difficulty": "Medium", "problem_description": "Given a sentence text (A sentence is a string of space-separated words) in the following format:\n\n- First letter is in upper case.\n- Each word in text are separated by a single space.\n\nYour task is to rearrange the words in text such that all words are rearranged in an increasing order of their lengths. If two words have the same length, arrange them in their original order.\n\nReturn the new text following the format shown above.\n\nExample 1:\n\nInput: text = \"Leetcode is cool\"\nOutput: \"Is cool leetcode\"\nExplanation: There are 3 words, \"Leetcode\" of length 8, \"is\" of length 2 and \"cool\" of length 4.\nOutput is ordered by length and the new first word starts with capital letter.\n\nExample 2:\n\nInput: text = \"Keep calm and code on\"\nOutput: \"On and keep calm code\"\nExplanation: Output is ordered as follows:\n\"On\" 2 letters.\n\"and\" 3 letters.\n\"keep\" 4 letters in case of tie order by position in original text.\n\"calm\" 4 letters.\n\"code\" 4 letters.\n\nExample 3:\n\nInput: text = \"To be or not to be\"\nOutput: \"To be or to be not\"\n\nConstraints:\n\n- text begins with a capital letter and then contains lowercase letters and single space between words.\n- 1 <= text.length <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"A quick brown fox jumps over the lazy dog\") == \"A fox the dog over lazy quick brown jumps\"\n assert candidate(text = \"This is a simple test case\") == \"A is this test case simple\"\n assert candidate(text = \"The weather is sunny\") == \"Is the sunny weather\"\n assert candidate(text = \"A\") == \"A\"\n assert candidate(text = \"A B C D E\") == \"A B C D E\"\n assert candidate(text = \"Pack my box with five dozen liquor jugs\") == \"My box pack with five jugs dozen liquor\"\n assert candidate(text = \"Sorting words by length is fun\") == \"By is fun words length sorting\"\n assert candidate(text = \"I love programming in Python\") == \"I in love Python programming\"\n assert candidate(text = \"How vexingly quick daft zebras jump\") == \"How daft jump quick zebras vexingly\"\n assert candidate(text = \"Every good boy does fine\") == \"Boy good does fine every\"\n assert candidate(text = \"To be or not to be\") == \"To be or to be not\"\n assert candidate(text = \"Leetcode is cool\") == \"Is cool leetcode\"\n assert candidate(text = \"The quick brown fox jumps over the lazy dog\") == \"The fox the dog over lazy quick brown jumps\"\n assert candidate(text = \"This is a test sentence with various word lengths\") == \"A is this test with word various lengths sentence\"\n assert candidate(text = \"Keep calm and code on\") == \"On and keep calm code\"\n assert candidate(text = \"This is a test sentence for the function\") == \"A is for the this test sentence function\"\n assert candidate(text = \"In computer science algorithms often require creative solutions\") == \"In often science require computer creative solutions algorithms\"\n assert candidate(text = \"Silent nights filled with the promise of new beginnings\") == \"Of the new with silent nights filled promise beginnings\"\n assert candidate(text = \"Beautiful sentences flow rhythmically and gracefully\") == \"And flow beautiful sentences gracefully rhythmically\"\n assert candidate(text = \"Health and happiness are the most valuable possessions\") == \"And are the most health valuable happiness possessions\"\n assert candidate(text = \"Exploring the mysteries of the universe is a lifelong journey\") == \"A of is the the journey universe lifelong exploring mysteries\"\n assert candidate(text = \"Understanding these concepts is crucial for programming\") == \"Is for these crucial concepts programming understanding\"\n assert candidate(text = \"Repeating words like test test test should stay in order\") == \"In like test test test stay words order should repeating\"\n assert candidate(text = \"Programming challenges are a great way to improve your skills\") == \"A to are way your great skills improve challenges programming\"\n assert candidate(text = \"The smallest words often hide the deepest meanings\") == \"The the hide words often deepest smallest meanings\"\n assert candidate(text = \"You are never too old to set another goal or to dream a new dream\") == \"A to or to you are too old set new goal never dream dream another\"\n assert candidate(text = \"Sorting algorithms like quicksort and mergesort\") == \"And like sorting quicksort mergesort algorithms\"\n assert candidate(text = \"Learning never stops no matter how much one knows\") == \"No how one much never stops knows matter learning\"\n assert candidate(text = \"Despite its simplicity Unix is a powerful and flexible operating system\") == \"A is its and Unix system despite powerful flexible operating simplicity\"\n assert candidate(text = \"A journey of a thousand miles begins with a single step\") == \"A a a of with step miles begins single journey thousand\"\n assert candidate(text = \"Problem-solving skills are highly valued in the tech industry\") == \"In are the tech skills highly valued industry problem-solving\"\n assert candidate(text = \"Complexity arises when multiple words share the same length\") == \"The when same words share arises length multiple complexity\"\n assert candidate(text = \"In the midst of winter I found there was, within me, an invincible summer\") == \"I in of an the me, was, midst found there winter within summer invincible\"\n assert candidate(text = \"Happiness is not something ready made. It comes from your own actions\") == \"Is It not own from your ready made. comes actions happiness something\"\n assert candidate(text = \"Small steps lead to big progress\") == \"To big lead small steps progress\"\n assert candidate(text = \"With unwavering determination, she embarked on the perilous journey\") == \"On she the with journey embarked perilous unwavering determination,\"\n assert candidate(text = \"BeautifulSoup lxml html parser are widely used for web scraping\") == \"Are for web lxml html used parser widely scraping beautifulsoup\"\n assert candidate(text = \"Sorting words by length while maintaining original order\") == \"By words while order length sorting original maintaining\"\n assert candidate(text = \"We may encounter many defeats but we must not be defeated\") == \"We we be may but not many must defeats defeated encounter\"\n assert candidate(text = \"To achieve great things, we must not only act, but also dream; not only plan, but also believe\") == \"To we not but not but must only act, also only also great plan, dream; achieve things, believe\"\n assert candidate(text = \"A beautiful butterfly gracefully flutters among the colorful flowers\") == \"A the among flowers flutters colorful beautiful butterfly gracefully\"\n assert candidate(text = \"The greatest glory in living lies not in never falling, but in rising every time we fall\") == \"In in in we the not but lies time fall glory never every living rising greatest falling,\"\n assert candidate(text = \"The only way to do great work is to love what you do\") == \"To do is to do the way you only work love what great\"\n assert candidate(text = \"Innovative solutions can be achieved through collaborative efforts\") == \"Be can through efforts achieved solutions innovative collaborative\"\n assert candidate(text = \"Documentation plays a vital role in software development\") == \"A in role plays vital software development documentation\"\n assert candidate(text = \"In the heart of the city stood a magnificent gothic cathedral\") == \"A in of the the city heart stood gothic cathedral magnificent\"\n assert candidate(text = \"In the realm of competitive programming challenges are vast\") == \"In of the are vast realm challenges competitive programming\"\n assert candidate(text = \"In the heart of the city, amidst towering skyscrapers, lies a hidden gem\") == \"A in of the the gem lies heart city, amidst hidden towering skyscrapers,\"\n assert candidate(text = \"Continuous integration and deployment practices improve software quality\") == \"And improve quality software practices continuous deployment integration\"\n assert candidate(text = \"When words are of equal length they should remain in order\") == \"Of in are when they words equal order length should remain\"\n assert candidate(text = \"Understanding the nuances of human behavior is crucial\") == \"Of is the human nuances crucial behavior understanding\"\n assert candidate(text = \"Sometimes simplicity is the ultimate sophistication\") == \"Is the ultimate sometimes simplicity sophistication\"\n assert candidate(text = \"Beautiful scenery can uplift one's spirits\") == \"Can one's uplift scenery spirits beautiful\"\n assert candidate(text = \"If you want to live a happy life, tie it to a goal, not to people or things\") == \"A a if to it to to or you tie not want live happy life, goal, people things\"\n assert candidate(text = \"Consistency is the key to achieving long-term success\") == \"Is to the key success achieving long-term consistency\"\n assert candidate(text = \"The rapid expansion of cloud computing services has transformed many industries\") == \"Of the has many rapid cloud services expansion computing industries transformed\"\n assert candidate(text = \"Data structures and algorithms form the backbone of software\") == \"Of and the data form backbone software structures algorithms\"\n assert candidate(text = \"When faced with difficult problems persistence is key\") == \"Is key when with faced problems difficult persistence\"\n assert candidate(text = \"The sound of crashing waves soothed his restless mind\") == \"Of the his mind sound waves soothed crashing restless\"\n assert candidate(text = \"Effective communication skills are crucial in software engineering\") == \"In are skills crucial software effective engineering communication\"\n assert candidate(text = \"Can you solve this complex rearrangement problem\") == \"Can you this solve complex problem rearrangement\"\n assert candidate(text = \"Keep smiling because life is a beautiful journey not a destination\") == \"A a is not keep life smiling because journey beautiful destination\"\n assert candidate(text = \"Given a string containing multiple words of different lengths\") == \"A of given words string lengths multiple different containing\"\n assert candidate(text = \"A quick brown fox jumps over the lazy dog in an unexpected manner\") == \"A in an fox the dog over lazy quick brown jumps manner unexpected\"\n assert candidate(text = \"Programming challenges often require deep understanding and patience\") == \"And deep often require patience challenges programming understanding\"\n assert candidate(text = \"Adapting to new technologies and methodologies is important\") == \"To is new and adapting important technologies methodologies\"\n assert candidate(text = \"Handling edge cases is important for robust code\") == \"Is for edge code cases robust handling important\"\n assert candidate(text = \"Understanding data structures is crucial for computer scientists\") == \"Is for data crucial computer structures scientists understanding\"\n assert candidate(text = \"Programming challenges are intellectually stimulating\") == \"Are challenges programming stimulating intellectually\"\n assert candidate(text = \"Efficient algorithms can significantly reduce computation time\") == \"Can time reduce efficient algorithms computation significantly\"\n assert candidate(text = \"Believe you can and you're halfway there\") == \"You can and there you're believe halfway\"\n assert candidate(text = \"Actions speak louder than words\") == \"Than speak words louder actions\"\n assert candidate(text = \"Complex algorithms often require sophisticated data structures\") == \"Data often complex require algorithms structures sophisticated\"\n assert candidate(text = \"Python programming language is powerful and versatile\") == \"Is and python language powerful versatile programming\"\n assert candidate(text = \"In the realm of possibilities, anything is achievable\") == \"In of is the realm anything achievable possibilities,\"\n assert candidate(text = \"Learning to code is one of the most empowering experiences\") == \"To is of one the code most learning empowering experiences\"\n assert candidate(text = \"Crafting intricate designs in wood requires both skill and creativity\") == \"In and wood both skill designs crafting requires intricate creativity\"\n assert candidate(text = \"Despite the odds being stacked against him, he never gave up hope\") == \"He up the odds him, gave hope being never despite stacked against\"\n assert candidate(text = \"Those who dare to fail miserably can achieve greatly\") == \"To who can dare fail those achieve greatly miserably\"\n assert candidate(text = \"May the Force be with you\") == \"Be may the you with Force\"\n assert candidate(text = \"Every problem has a unique solution waiting to be discovered\") == \"A to be has every unique problem waiting solution discovered\"\n assert candidate(text = \"Consider various scenarios when testing your solution\") == \"When your various testing consider solution scenarios\"\n assert candidate(text = \"Despite the harsh conditions, the resilient hikers forged ahead\") == \"The the harsh ahead hikers forged despite resilient conditions,\"\n assert candidate(text = \"The ancient ruins whispered tales of forgotten civilizations\") == \"Of the ruins tales ancient whispered forgotten civilizations\"\n assert candidate(text = \"Python programming can be quite challenging indeed\") == \"Be can quite python indeed programming challenging\"\n assert candidate(text = \"Resilience and determination are the keys to success\") == \"To and are the keys success resilience determination\"\n assert candidate(text = \"A very very long sentence that needs to be properly rearranged\") == \"A to be very very long that needs sentence properly rearranged\"\n assert candidate(text = \"When sorting algorithms fail gracefully\") == \"When fail sorting algorithms gracefully\"\n assert candidate(text = \"Adventure and exploration are essential for personal growth\") == \"And are for growth personal adventure essential exploration\"\n assert candidate(text = \"Python Java JavaScript and C are popular programming languages\") == \"C and are Java python popular languages JavaScript programming\"\n assert candidate(text = \"Algorithms and data structures are fundamental to computer science\") == \"To and are data science computer algorithms structures fundamental\"\n assert candidate(text = \"In the heart of autumn leaves change their colors\") == \"In of the heart their autumn leaves change colors\"\n assert candidate(text = \"If life were predictable it would cease to be life, and be without flavor\") == \"If it to be be and life were would cease life, flavor without predictable\"\n assert candidate(text = \"A storm of emotions surged through her heart\") == \"A of her storm heart surged through emotions\"\n assert candidate(text = \"Continuous improvement is the hallmark of excellence\") == \"Is of the hallmark continuous excellence improvement\"\n assert candidate(text = \"The rain in Spain stays mainly in the plain\") == \"In in the the rain Spain stays plain mainly\"\n assert candidate(text = \"Do not watch the clock; do what it does. Keep going\") == \"Do do it not the what Keep watch does. going clock;\"\n assert candidate(text = \"The rapid expansion of artificial intelligence is fascinating\") == \"Of is the rapid expansion artificial fascinating intelligence\"\n assert candidate(text = \"An extraordinary journey through the magical lands\") == \"An the lands journey through magical extraordinary\"\n assert candidate(text = \"The early morning light illuminated the dew-kissed grass\") == \"The the early light grass morning dew-kissed illuminated\"\n assert candidate(text = \"Python is an interpreted high level programming language\") == \"Is an high level python language interpreted programming\"\n assert candidate(text = \"Understanding the intricacies of quantum mechanics requires patience\") == \"Of the quantum requires patience mechanics intricacies understanding\"\n assert candidate(text = \"A bird in the hand is worth two in the bush\") == \"A in is in the two the bird hand bush worth\"\n assert candidate(text = \"XMLHttpRequest allows clients to send and receive data asynchronously without reloading the web page\") == \"To and the web send data page allows clients receive without reloading xmlhttprequest asynchronously\"\n assert candidate(text = \"An overwhelming sense of serenity filled the quaint village\") == \"An of the sense filled quaint village serenity overwhelming\"\n assert candidate(text = \"Beautiful minds think in unpredictable ways\") == \"In ways minds think beautiful unpredictable\"\n assert candidate(text = \"Artificial intelligence and machine learning are transforming industries\") == \"And are machine learning artificial industries intelligence transforming\"\n assert candidate(text = \"It is during our darkest moments that we must focus the light\") == \"It is we our the that must focus light during darkest moments\"\n assert candidate(text = \"Do what you can with all you have, wherever you are\") == \"Do you can all you you are what with have, wherever\"\n assert candidate(text = \"Python is an interpreted high-level general-purpose programming language\") == \"Is an python language high-level interpreted programming general-purpose\"\n assert candidate(text = \"Sometimes life gives you lemons and you make lemonade\") == \"You and you life make gives lemons lemonade sometimes\"\n assert candidate(text = \"Creativity is the key to solving complex problems\") == \"Is to the key solving complex problems creativity\"\n assert candidate(text = \"Even seemingly simple tasks can be complex\") == \"Be can even tasks simple complex seemingly\"\n assert candidate(text = \"Data structures like arrays and linked lists\") == \"And data like lists arrays linked structures\"\n assert candidate(text = \"In computer science algorithms are fundamental\") == \"In are science computer algorithms fundamental\"\n assert candidate(text = \"Wherever you go, go with all your heart\") == \"Go you go, all with your heart wherever\"\n assert candidate(text = \"The magic of books lies in the stories they hold\") == \"Of in the the lies they hold magic books stories\"\n assert candidate(text = \"The children laughed joyfully in the sunlit playground\") == \"In the the sunlit laughed children joyfully playground\"\n assert candidate(text = \"The best time to plant a tree was 20 years ago. The second best time is now\") == \"A to 20 is the was The now best time tree ago. best time plant years second\"\n assert candidate(text = \"This is a test to see if the function handles ties correctly\") == \"A is to if see the this test ties handles function correctly\"\n assert candidate(text = \"Nature's beauty is a constant source of inspiration\") == \"A is of beauty source nature's constant inspiration\"\n assert candidate(text = \"Despite its simplicity quicksort is incredibly effective\") == \"Is its despite quicksort effective simplicity incredibly\"\n assert candidate(text = \"Programming challenges are a great way to improve skills\") == \"A to are way great skills improve challenges programming\"\n assert candidate(text = \"Check if the function can handle sentences with repeated words\") == \"If the can with check words handle function repeated sentences\"\n assert candidate(text = \"In every day, there are 1440 minutes, 86400 seconds and 5184000 milliseconds, so live every second\") == \"In so are and day, 1440 live every there 86400 every second seconds 5184000 minutes, milliseconds,\"\n assert candidate(text = \"Somebody once told me the world is gonna roll me\") == \"Me is me the once told roll world gonna somebody\"\n assert candidate(text = \"Many software projects involve working with multiple programming languages\") == \"Many with involve working software projects multiple languages programming\"\n assert candidate(text = \"Version control systems are essential for software development\") == \"Are for version control systems software essential development\"\n assert candidate(text = \"Writing clean and maintainable code is beneficial\") == \"Is and code clean writing beneficial maintainable\"\n assert candidate(text = \"Understanding the complexities of software development requires patience\") == \"Of the software requires patience development complexities understanding\"\n assert candidate(text = \"Debugging is twice as hard as writing the code in the first place\") == \"Is as as in the the hard code twice first place writing debugging\"\n assert candidate(text = \"Handling large datasets efficiently is a common requirement\") == \"A is large common handling datasets efficiently requirement\"\n assert candidate(text = \"Sometimes simple sentences are the most powerful\") == \"Are the most simple powerful sometimes sentences\"\n assert candidate(text = \"Algorithms data structures and programming languages\") == \"And data languages algorithms structures programming\"\n assert candidate(text = \"Some programmers prefer to use snake_case others CamelCase\") == \"To use some prefer others CamelCase snake_case programmers\"\n assert candidate(text = \"Exploring new cultures broadens one's horizons immensely\") == \"New one's cultures broadens horizons exploring immensely\"\n assert candidate(text = \"This is a simple example to demonstrate the functionality\") == \"A is to the this simple example demonstrate functionality\"\n assert candidate(text = \"Efficient algorithms can significantly reduce processing time\") == \"Can time reduce efficient algorithms processing significantly\"\n assert candidate(text = \"Python programming challenges are incredibly rewarding\") == \"Are python rewarding challenges incredibly programming\"\n assert candidate(text = \"Do not judge each day by the harvest you reap but by the seeds that you plant\") == \"Do by by not day the you but the you each reap that judge seeds plant harvest\"\n assert candidate(text = \"The quick movement of the enemy will jeopardize six gunboats\") == \"Of the the six will quick enemy movement gunboats jeopardize\"\n assert candidate(text = \"Contrary to popular belief Lorem Ipsum is not simply random text\") == \"To is not text Lorem Ipsum belief simply random popular contrary\"\n assert candidate(text = \"Every small victory is a stepping stone to greatness\") == \"A is to every small stone victory stepping greatness\"\n assert candidate(text = \"A mix of long and short words challenges the function greatly\") == \"A of mix and the long short words greatly function challenges\"\n assert candidate(text = \"Innovative solutions require creative thinking processes\") == \"Require creative thinking solutions processes innovative\"\n assert candidate(text = \"Consistency is the bridge between goals and accomplishment\") == \"Is the and goals bridge between consistency accomplishment\"\n assert candidate(text = \"An apple a day keeps the doctor away\") == \"A an day the away apple keeps doctor\"\n assert candidate(text = \"The scent of blooming roses filled the tranquil garden\") == \"Of the the scent roses filled garden blooming tranquil\"\n assert candidate(text = \"In the end we will remember not the words of our enemies but the silence of our friends\") == \"In we of of the end not the our but the our will words enemies silence friends remember\"\n assert candidate(text = \"Edge cases like very long words or many short ones\") == \"Or edge like very long many ones cases words short\"\n assert candidate(text = \"The future belongs to those who believe in the beauty of their dreams\") == \"To in of the who the those their future beauty dreams belongs believe\"\n assert candidate(text = \"Innovative solutions drive technological advancement\") == \"Drive solutions innovative advancement technological\"\n", "comparison": "exact"}, "public_tests": ["\"Leetcode is cool\"", "\"Keep calm and code on\"", "\"To be or not to be\""], "hints": ["Store each word and their relative position. Then, sort them by length of words in case of tie by their original order."], "metadata": {"canonical_parameter_names": ["text"], "leetcode_dataset_entry_point": "Solution().arrangeWords", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:35+00:00", "tests_total": 152, "tests_dropped": 0, "flags": ["figure_reference"], "topic_tags": ["string", "sorting"]}, "language": "java", "interface": {"raw_signature": "public String arrangeWords(String text) {", "container": "Solution", "callable": "arrangeWords", "parameters": [{"name": "text", "type": "String"}], "return_type": "String", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1452, "task_id": "people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list", "difficulty": "Medium", "problem_description": "Given the array favoriteCompanies where favoriteCompanies[i] is the list of favorites companies for the ith person (indexed from 0).\n\nReturn the indices of people whose list of favorite companies is not a subset of any other list of favorites companies. You must return the indices in increasing order.\n\nExample 1:\n\nInput: favoriteCompanies = [[\"leetcode\",\"google\",\"facebook\"],[\"google\",\"microsoft\"],[\"google\",\"facebook\"],[\"google\"],[\"amazon\"]]\nOutput: [0,1,4]\nExplanation:\nPerson with index=2 has favoriteCompanies[2]=[\"google\",\"facebook\"] which is a subset of favoriteCompanies[0]=[\"leetcode\",\"google\",\"facebook\"] corresponding to the person with index 0.\nPerson with index=3 has favoriteCompanies[3]=[\"google\"] which is a subset of favoriteCompanies[0]=[\"leetcode\",\"google\",\"facebook\"] and favoriteCompanies[1]=[\"google\",\"microsoft\"].\nOther lists of favorite companies are not a subset of another list, therefore, the answer is [0,1,4].\n\nExample 2:\n\nInput: favoriteCompanies = [[\"leetcode\",\"google\",\"facebook\"],[\"leetcode\",\"amazon\"],[\"facebook\",\"google\"]]\nOutput: [0,1]\nExplanation: In this case favoriteCompanies[2]=[\"facebook\",\"google\"] is a subset of favoriteCompanies[0]=[\"leetcode\",\"google\",\"facebook\"], therefore, the answer is [0,1].\n\nExample 3:\n\nInput: favoriteCompanies = [[\"leetcode\"],[\"google\"],[\"facebook\"],[\"amazon\"]]\nOutput: [0,1,2,3]\n\nConstraints:\n\n- 1 <= favoriteCompanies.length <= 100\n- 1 <= favoriteCompanies[i].length <= 500\n- 1 <= favoriteCompanies[i][j].length <= 20\n- All strings in favoriteCompanies[i] are distinct.\n- All lists of favorite companies are distinct, that is, If we sort alphabetically each list then favoriteCompanies[i] != favoriteCompanies[j].\n- All strings consist of lowercase English letters only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(favoriteCompanies = [['leetcode'], ['google'], ['facebook'], ['amazon']]) == [0, 1, 2, 3]\n assert candidate(favoriteCompanies = [['apple'], ['apple', 'google'], ['google', 'facebook'], ['apple', 'facebook', 'google']]) == [3]\n assert candidate(favoriteCompanies = [['tech', 'innovation'], ['startup', 'tech'], ['innovation', 'startup', 'tech']]) == [2]\n assert candidate(favoriteCompanies = [['leetcode', 'google', 'facebook'], ['leetcode', 'amazon'], ['facebook', 'google']]) == [0, 1]\n assert candidate(favoriteCompanies = [['apple'], ['apple', 'google'], ['google', 'facebook'], ['facebook', 'microsoft']]) == [1, 2, 3]\n assert candidate(favoriteCompanies = [['leetcode', 'google', 'facebook'], ['google', 'microsoft'], ['google', 'facebook'], ['google'], ['amazon']]) == [0, 1, 4]\n assert candidate(favoriteCompanies = [['apple', 'microsoft'], ['google'], ['apple', 'google', 'microsoft'], ['google', 'microsoft']]) == [2]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry'], ['banana'], ['apple', 'banana']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana'], ['apple', 'orange'], ['banana', 'orange'], ['apple']]) == [0, 2, 3]\n assert candidate(favoriteCompanies = [['apple'], ['banana'], ['cherry'], ['date'], ['elderberry']]) == [0, 1, 2, 3, 4]\n assert candidate(favoriteCompanies = [['apple', 'google'], ['google'], ['apple', 'microsoft'], ['facebook']]) == [0, 2, 3]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date'], ['banana', 'date'], ['apple', 'banana', 'cherry']]) == [1, 2, 4]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date', 'fig'], ['banana', 'date', 'fig', 'grape'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'kiwi']]) == [4]\n assert candidate(favoriteCompanies = [['amazon', 'apple', 'facebook', 'google', 'microsoft'], ['google'], ['amazon', 'facebook'], ['apple', 'google', 'microsoft'], ['amazon', 'google', 'microsoft', 'apple', 'facebook']]) == []\n assert candidate(favoriteCompanies = [['airbnb', 'expedia', 'booking'], ['expedia', 'tripadvisor', 'kayak'], ['booking', 'tripadvisor', 'kayak'], ['airbnb', 'tripadvisor', 'kayak'], ['expedia', 'booking', 'tripadvisor'], ['airbnb', 'expedia', 'booking', 'tripadvisor', 'kayak']]) == [5]\n assert candidate(favoriteCompanies = [['apple', 'microsoft', 'amazon'], ['google', 'facebook', 'apple'], ['amazon', 'google', 'microsoft', 'facebook'], ['google'], ['microsoft', 'facebook']]) == [0, 1, 2]\n assert candidate(favoriteCompanies = [['leetcode', 'google'], ['google'], ['google', 'facebook'], ['google', 'facebook', 'microsoft'], ['google', 'facebook', 'microsoft', 'amazon'], ['amazon'], ['amazon', 'google'], ['amazon', 'facebook'], ['amazon', 'microsoft'], ['amazon', 'google', 'facebook', 'microsoft']]) == [0]\n assert candidate(favoriteCompanies = [['linkedin', 'facebook', 'twitter'], ['linkedin', 'google', 'instagram'], ['facebook', 'instagram'], ['google', 'twitter'], ['facebook'], ['google'], ['twitter'], ['instagram'], ['linkedin'], ['facebook', 'google', 'instagram', 'twitter', 'linkedin']]) == [9]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry'], ['cherry', 'date'], ['apple', 'banana', 'cherry', 'date'], ['banana', 'date', 'apple'], ['apple', 'banana']]) == [3]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry'], ['cherry', 'date'], ['date', 'fig'], ['fig', 'grape'], ['grape', 'honeydew'], ['honeydew', 'kiwi'], ['kiwi', 'lemon'], ['lemon', 'mango'], ['mango', 'nectarine'], ['nectarine', 'orange'], ['orange', 'papaya'], ['papaya', 'quince'], ['quince', 'raspberry'], ['raspberry', 'strawberry'], ['strawberry', 'tangerine'], ['tangerine', 'ugli'], ['ugli', 'vanilla'], ['vanilla', 'watermelon'], ['watermelon', 'xigua'], ['xigua', 'yam'], ['yam', 'zucchini'], ['apple', 'banana', 'cherry'], ['banana', 'cherry', 'date'], ['cherry', 'date', 'fig'], ['date', 'fig', 'grape'], ['fig', 'grape', 'honeydew'], ['honeydew', 'kiwi', 'lemon'], ['kiwi', 'lemon', 'mango'], ['lemon', 'mango', 'nectarine'], ['mango', 'nectarine', 'orange'], ['nectarine', 'orange', 'papaya'], ['orange', 'papaya', 'quince'], ['papaya', 'quince', 'raspberry'], ['quince', 'raspberry', 'strawberry'], ['raspberry', 'strawberry', 'tangerine'], ['strawberry', 'tangerine', 'ugli'], ['tangerine', 'ugli', 'vanilla'], ['ugli', 'vanilla', 'watermelon'], ['vanilla', 'watermelon', 'xigua'], ['watermelon', 'xigua', 'yam'], ['xigua', 'yam', 'zucchini']]) == [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41]\n assert candidate(favoriteCompanies = [['a', 'b', 'c', 'd', 'e'], ['f', 'g', 'h', 'i', 'j'], ['a', 'b', 'c', 'd'], ['b', 'c', 'd', 'e'], ['a', 'b', 'c'], ['a', 'b'], ['a'], ['b'], ['c'], ['d'], ['e'], ['f'], ['g'], ['h'], ['i'], ['j']]) == [0, 1]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry'], ['cherry'], ['apple', 'cherry'], ['banana', 'cherry', 'date', 'fig'], ['date', 'fig']]) == [0, 4]\n assert candidate(favoriteCompanies = [['uber', 'lyft', 'careem'], ['careem', 'grab', 'gojek'], ['grab', 'uber', 'gojek'], ['gojek', 'grab'], ['careem', 'uber', 'lyft', 'grab', 'gojek']]) == [4]\n assert candidate(favoriteCompanies = [['amazon', 'apple', 'google'], ['google', 'microsoft'], ['facebook', 'google'], ['amazon', 'google', 'facebook'], ['microsoft', 'amazon'], ['amazon', 'facebook', 'google', 'microsoft'], ['apple', 'google', 'facebook']]) == [0, 5, 6]\n assert candidate(favoriteCompanies = [['tech', 'science', 'arts'], ['science', 'arts', 'literature'], ['tech', 'science'], ['science'], ['tech'], ['arts'], ['literature'], ['arts', 'literature'], ['tech', 'arts', 'literature'], ['tech', 'science', 'literature']]) == [0, 1, 8, 9]\n assert candidate(favoriteCompanies = [['tesla', 'toyota', 'ford'], ['toyota', 'ford', 'gm'], ['tesla', 'toyota', 'gm'], ['ford', 'gm'], ['tesla', 'toyota', 'ford', 'gm'], ['tesla', 'gm']]) == [4]\n assert candidate(favoriteCompanies = [['p', 'q', 'r'], ['q', 'r', 's'], ['r', 's', 't'], ['s', 't', 'u'], ['t', 'u', 'v'], ['u', 'v', 'w'], ['v', 'w', 'x'], ['w', 'x', 'y'], ['x', 'y', 'z'], ['y', 'z', 'p'], ['z', 'p', 'q'], ['p', 'q', 'r', 's'], ['q', 'r', 's', 't'], ['r', 's', 't', 'u'], ['s', 't', 'u', 'v'], ['t', 'u', 'v', 'w'], ['u', 'v', 'w', 'x'], ['v', 'w', 'x', 'y'], ['w', 'x', 'y', 'z'], ['x', 'y', 'z', 'p']]) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(favoriteCompanies = [['leetcode'], ['google'], ['facebook'], ['amazon'], ['apple'], ['twitter'], ['youtube'], ['instagram'], ['snapchat'], ['linkedin']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(favoriteCompanies = [['leetcode', 'google', 'facebook', 'amazon'], ['google', 'facebook', 'microsoft'], ['google', 'amazon'], ['amazon'], ['google'], ['facebook']]) == [0, 1]\n assert candidate(favoriteCompanies = [['netflix', 'amazon', 'hulu'], ['amazon', 'hbo', 'crunchyroll'], ['netflix', 'hbo', 'crunchyroll'], ['hulu', 'hbo', 'crunchyroll'], ['netflix', 'amazon', 'hbo', 'crunchyroll'], ['amazon', 'hbo']]) == [0, 3, 4]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry', 'date'], ['cherry', 'date', 'fig'], ['date', 'fig', 'grape'], ['fig', 'grape', 'apple'], ['grape', 'apple', 'banana'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape']]) == [6]\n assert candidate(favoriteCompanies = [['microsoft', 'apple', 'google', 'facebook'], ['google', 'microsoft'], ['facebook', 'apple'], ['apple', 'google', 'facebook'], ['microsoft', 'apple'], ['google', 'amazon'], ['amazon', 'facebook'], ['microsoft', 'google', 'facebook']]) == [0, 5, 6]\n assert candidate(favoriteCompanies = [['twitter'], ['twitter', 'instagram'], ['twitter', 'facebook'], ['instagram', 'facebook'], ['twitter', 'instagram', 'facebook'], ['twitter', 'google'], ['google', 'facebook'], ['instagram', 'google'], ['twitter', 'instagram', 'google', 'facebook']]) == [8]\n assert candidate(favoriteCompanies = [['leetcode'], ['leetcode', 'google'], ['google', 'facebook'], ['leetcode', 'facebook'], ['facebook', 'amazon'], ['google', 'amazon', 'facebook'], ['leetcode', 'amazon', 'google', 'facebook']]) == [6]\n assert candidate(favoriteCompanies = [['apple'], ['banana'], ['cherry'], ['date'], ['fig'], ['grape'], ['kiwi'], ['lemon'], ['mango'], ['orange']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(favoriteCompanies = [['google', 'apple'], ['google', 'apple', 'facebook'], ['google', 'facebook'], ['apple', 'facebook', 'microsoft'], ['google', 'microsoft'], ['apple', 'microsoft'], ['google', 'amazon'], ['apple', 'amazon'], ['facebook', 'amazon'], ['google', 'facebook', 'amazon', 'apple', 'microsoft']]) == [9]\n assert candidate(favoriteCompanies = [['spotify', 'apple', 'google'], ['apple', 'google', 'amazon'], ['google', 'microsoft', 'apple'], ['facebook', 'google', 'amazon'], ['twitter', 'google', 'apple'], ['spotify', 'google', 'microsoft'], ['apple', 'google', 'facebook'], ['google', 'amazon', 'microsoft'], ['twitter', 'facebook', 'microsoft'], ['google', 'apple', 'facebook', 'microsoft', 'amazon', 'twitter', 'spotify']]) == [9]\n assert candidate(favoriteCompanies = [['google', 'facebook', 'amazon', 'apple', 'microsoft'], ['google', 'facebook'], ['google', 'amazon'], ['google', 'apple'], ['google', 'microsoft'], ['facebook', 'amazon'], ['facebook', 'apple'], ['facebook', 'microsoft'], ['amazon', 'apple'], ['amazon', 'microsoft'], ['apple', 'microsoft'], ['google'], ['facebook'], ['amazon'], ['apple'], ['microsoft']]) == [0]\n assert candidate(favoriteCompanies = [['tech1', 'tech2', 'tech3', 'tech4'], ['tech2', 'tech3'], ['tech3', 'tech4'], ['tech4', 'tech1'], ['tech1', 'tech2'], ['tech2', 'tech3', 'tech4'], ['tech3', 'tech4', 'tech1'], ['tech4', 'tech1', 'tech2'], ['tech1', 'tech2', 'tech3']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['apple', 'banana'], ['banana', 'cherry'], ['apple', 'cherry'], ['date', 'fig', 'grape']]) == [0, 4]\n assert candidate(favoriteCompanies = [['x', 'y', 'z', 'w', 'v'], ['y', 'z'], ['z', 'w'], ['w', 'v'], ['v', 'x'], ['x', 'y'], ['y', 'z', 'w'], ['z', 'w', 'v'], ['w', 'v', 'x'], ['v', 'x', 'y'], ['x', 'y', 'z']]) == [0]\n assert candidate(favoriteCompanies = [['spotify', 'apple', 'deez', 'pandora'], ['apple', 'soundcloud', 'tidal'], ['deez', 'pandora', 'soundcloud'], ['spotify', 'soundcloud', 'tidal'], ['spotify', 'apple', 'deez', 'pandora', 'soundcloud', 'tidal']]) == [4]\n assert candidate(favoriteCompanies = [['uber', 'lyft', 'grubhub'], ['grubhub', 'doorDash', 'postmates'], ['lyft', 'postmates', 'uber'], ['uber', 'lyft', 'grubhub', 'doorDash', 'postmates'], ['postmates', 'grubhub'], ['uber', 'grubhub', 'doorDash'], ['grubhub', 'lyft', 'uber', 'postmates'], ['doorDash', 'lyft']]) == [3]\n assert candidate(favoriteCompanies = [['pinterest', 'quora', 'reddit'], ['quora', 'snapchat', 'twitter'], ['facebook', 'google', 'instagram'], ['linkedin', 'pinterest', 'quora', 'reddit'], ['facebook', 'google', 'instagram', 'linkedin', 'pinterest'], ['pinterest', 'quora', 'reddit', 'snapchat', 'twitter'], ['instagram', 'linkedin', 'pinterest', 'quora', 'reddit']]) == [4, 5, 6]\n assert candidate(favoriteCompanies = [['tech1', 'tech2', 'tech3', 'tech4'], ['tech1', 'tech2'], ['tech2', 'tech3'], ['tech3', 'tech4'], ['tech4', 'tech1'], ['tech2', 'tech4'], ['tech1', 'tech3'], ['tech1', 'tech2', 'tech3'], ['tech2', 'tech3', 'tech4'], ['tech1', 'tech2', 'tech4']]) == [0]\n assert candidate(favoriteCompanies = [['techcrunch', 'theverge'], ['theverge', 'recode'], ['techcrunch', 'recode', 'theverge'], ['theverge', 'cnet'], ['recode', 'cnet', 'theverge'], ['techcrunch', 'cnet'], ['recode', 'cnet'], ['techcrunch', 'recode', 'theverge', 'cnet'], ['cnet', 'theverge'], ['recode', 'theverge', 'cnet'], ['techcrunch', 'theverge', 'cnet', 'recode'], ['cnet'], ['techcrunch'], ['recode']]) == []\n assert candidate(favoriteCompanies = [['xbox', 'playstation', 'nintendo'], ['nintendo', 'sega'], ['playstation', 'nintendo', 'sega'], ['xbox', 'nintendo'], ['playstation', 'sega'], ['xbox', 'playstation', 'nintendo', 'sega'], ['xbox', 'playstation'], ['nintendo']]) == [5]\n assert candidate(favoriteCompanies = [['microsoft', 'amazon', 'google'], ['google'], ['amazon'], ['microsoft'], ['google', 'amazon'], ['google', 'microsoft'], ['microsoft', 'amazon'], ['amazon', 'google'], ['google', 'microsoft', 'amazon'], ['google', 'microsoft', 'amazon', 'facebook']]) == [9]\n assert candidate(favoriteCompanies = [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['b', 'c'], ['c', 'd', 'e'], ['d', 'e', 'f'], ['e', 'f', 'g'], ['f', 'g', 'h'], ['g', 'h'], ['h']]) == [0]\n assert candidate(favoriteCompanies = [['amazon', 'ebay', 'google'], ['google', 'microsoft'], ['ebay', 'microsoft'], ['amazon', 'microsoft'], ['amazon', 'ebay', 'google', 'microsoft']]) == [4]\n assert candidate(favoriteCompanies = [['ibm', 'apple', 'microsoft'], ['apple', 'google', 'amazon'], ['ibm', 'google', 'amazon'], ['microsoft', 'amazon'], ['ibm', 'apple', 'google', 'amazon'], ['apple', 'microsoft', 'google'], ['ibm', 'google']]) == [0, 3, 4, 5]\n assert candidate(favoriteCompanies = [['facebook', 'instagram'], ['instagram', 'snapchat'], ['facebook', 'snapchat'], ['facebook', 'instagram', 'snapchat'], ['facebook'], ['snapchat'], ['instagram']]) == [3]\n assert candidate(favoriteCompanies = [['amazon', 'google', 'apple'], ['google', 'facebook', 'microsoft'], ['amazon', 'facebook', 'apple'], ['google', 'amazon', 'facebook', 'microsoft'], ['google', 'apple']]) == [0, 2, 3]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry'], ['cherry', 'date'], ['date', 'elderberry'], ['elderberry', 'fig'], ['fig', 'grape'], ['grape', 'honeydew'], ['honeydew', 'apple']]) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date'], ['banana', 'date'], ['apple', 'banana', 'cherry'], ['apple', 'banana', 'cherry', 'date'], ['apple', 'banana', 'cherry', 'date', 'fig']]) == [6]\n assert candidate(favoriteCompanies = [['apple'], ['banana'], ['cherry'], ['date'], ['elderberry'], ['fig'], ['grape'], ['honeydew'], ['kiwi'], ['lemon'], ['mango'], ['nectarine'], ['orange'], ['papaya'], ['quince'], ['raspberry'], ['strawberry'], ['tangerine'], ['ugli'], ['vanilla'], ['watermelon'], ['xigua'], ['yam'], ['zucchini']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'date', 'elderberry'], ['apple', 'banana', 'cherry', 'date', 'elderberry'], ['cherry', 'date'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape']]) == [2, 4]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date'], ['cherry', 'date', 'fig'], ['apple', 'banana', 'date', 'fig'], ['banana', 'date', 'fig', 'grape'], ['apple', 'cherry', 'fig', 'grape'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape'], ['banana', 'cherry', 'date', 'fig', 'grape', 'honeydew'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'honeydew'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi'], ['banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon'], ['banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon', 'mango'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon', 'mango'], ['banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon', 'mango', 'nectarine']]) == [14, 15]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['cherry', 'date'], ['apple', 'banana'], ['banana', 'cherry', 'date'], ['apple', 'banana', 'cherry', 'date']]) == [4]\n assert candidate(favoriteCompanies = [['a', 'b', 'c', 'd', 'e'], ['a', 'b'], ['b', 'c'], ['c', 'd'], ['d', 'e'], ['e', 'a'], ['a', 'c'], ['b', 'd'], ['c', 'e'], ['d', 'a'], ['e', 'b'], ['a', 'b', 'c'], ['b', 'c', 'd'], ['c', 'd', 'e'], ['d', 'e', 'a'], ['e', 'a', 'b']]) == [0]\n assert candidate(favoriteCompanies = [['company1'], ['company2'], ['company3'], ['company4'], ['company5'], ['company6'], ['company7'], ['company8'], ['company9'], ['company10'], ['company11'], ['company12'], ['company13'], ['company14'], ['company15'], ['company16'], ['company17'], ['company18'], ['company19'], ['company20'], ['company21'], ['company22'], ['company23'], ['company24'], ['company25'], ['company26'], ['company27'], ['company28'], ['company29'], ['company30']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry'], ['cherry', 'date'], ['date', 'fig'], ['fig', 'grape'], ['grape', 'honeydew'], ['honeydew', 'kiwi'], ['kiwi', 'lemon'], ['lemon', 'mango'], ['mango', 'nectarine'], ['nectarine', 'orange'], ['orange', 'papaya'], ['papaya', 'quince'], ['quince', 'raspberry'], ['raspberry', 'strawberry'], ['strawberry', 'tangerine'], ['tangerine', 'ugli'], ['ugli', 'vanilla'], ['vanilla', 'watermelon'], ['watermelon', 'xigua'], ['xigua', 'yam'], ['yam', 'zucchini']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]\n assert candidate(favoriteCompanies = [['one', 'two', 'three'], ['two', 'three', 'four'], ['three', 'four', 'five'], ['four', 'five', 'six'], ['five', 'six', 'seven'], ['six', 'seven', 'eight'], ['seven', 'eight', 'nine'], ['eight', 'nine', 'ten'], ['nine', 'ten', 'one'], ['ten', 'one', 'two']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(favoriteCompanies = [['honda', 'toyota', 'mazda'], ['toyota', 'nissan', 'mitsubishi'], ['honda', 'toyota', 'nissan', 'mitsubishi'], ['mazda', 'nissan', 'mitsubishi'], ['honda', 'toyota', 'mazda', 'nissan', 'mitsubishi']]) == [4]\n assert candidate(favoriteCompanies = [['amazon', 'apple', 'facebook', 'google'], ['apple', 'facebook'], ['amazon', 'google'], ['facebook', 'google'], ['amazon', 'facebook', 'google'], ['apple', 'google']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry', 'date', 'elderberry'], ['banana', 'cherry', 'date', 'fig'], ['apple', 'banana', 'date', 'fig', 'grape'], ['cherry', 'date', 'fig', 'grape', 'honeydew'], ['apple', 'cherry', 'fig', 'grape', 'honeydew'], ['banana', 'cherry', 'grape', 'honeydew']]) == [0, 1, 2, 3, 4, 5]\n assert candidate(favoriteCompanies = [['alibaba', 'tencent', 'jd'], ['tencent', 'xiami', 'sina'], ['jd', 'xiami', 'sina'], ['alibaba', 'tencent', 'jd', 'sina'], ['xiami', 'sina'], ['alibaba', 'jd']]) == [1, 2, 3]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry', 'date'], ['banana', 'cherry'], ['apple', 'cherry', 'date'], ['cherry', 'date'], ['apple', 'banana', 'cherry'], ['banana', 'date'], ['apple', 'banana', 'cherry', 'date', 'elderberry'], ['banana', 'cherry', 'date', 'fig'], ['apple', 'banana', 'date', 'fig', 'grape'], ['cherry', 'date', 'fig', 'grape', 'honeydew'], ['apple', 'cherry', 'fig', 'grape', 'honeydew'], ['banana', 'cherry', 'grape', 'honeydew']]) == [6, 7, 8, 9, 10, 11]\n assert candidate(favoriteCompanies = [['google'], ['google', 'facebook'], ['google', 'facebook', 'amazon'], ['google', 'facebook', 'amazon', 'apple'], ['google', 'facebook', 'amazon', 'apple', 'microsoft'], ['google', 'facebook', 'amazon', 'apple', 'microsoft', 'netflix'], ['google', 'facebook', 'amazon', 'apple', 'microsoft', 'netflix', 'spotify']]) == [6]\n assert candidate(favoriteCompanies = [['microsoft', 'google'], ['google', 'facebook'], ['leetcode', 'google', 'facebook'], ['google'], ['amazon'], ['microsoft', 'amazon'], ['amazon', 'google']]) == [0, 2, 5, 6]\n assert candidate(favoriteCompanies = [['apple', 'google', 'facebook', 'microsoft'], ['google', 'facebook', 'microsoft'], ['apple', 'facebook', 'microsoft'], ['apple', 'google', 'microsoft'], ['apple', 'google', 'facebook'], ['facebook', 'microsoft'], ['google', 'microsoft'], ['apple', 'microsoft'], ['apple', 'google'], ['apple', 'facebook']]) == [0]\n assert candidate(favoriteCompanies = [['netflix', 'hulu'], ['hulu', 'crunchyroll'], ['netflix', 'crunchyroll'], ['netflix', 'hulu', 'crunchyroll'], ['netflix', 'hulu', 'crunchyroll', 'disney'], ['disney'], ['netflix'], ['hulu'], ['crunchyroll'], ['netflix', 'hulu', 'disney'], ['hulu', 'crunchyroll', 'disney'], ['netflix', 'crunchyroll', 'disney']]) == [4]\n assert candidate(favoriteCompanies = [['google', 'amazon', 'facebook'], ['google', 'amazon'], ['google'], ['amazon'], ['facebook'], ['google', 'facebook'], ['amazon', 'facebook']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry'], ['apple', 'cherry'], ['cherry'], ['apple', 'banana'], ['banana']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'microsoft', 'google'], ['amazon', 'apple', 'microsoft'], ['apple', 'google'], ['google', 'microsoft'], ['facebook', 'google', 'microsoft', 'amazon'], ['apple', 'banana', 'cherry']]) == [0, 1, 4, 5]\n", "comparison": "exact"}, "public_tests": ["[[\"leetcode\",\"google\",\"facebook\"],[\"google\",\"microsoft\"],[\"google\",\"facebook\"],[\"google\"],[\"amazon\"]]", "[[\"leetcode\",\"google\",\"facebook\"],[\"leetcode\",\"amazon\"],[\"facebook\",\"google\"]]", "[[\"leetcode\"],[\"google\"],[\"facebook\"],[\"amazon\"]]"], "hints": ["Use hashing to convert company names in numbers and then for each list check if this is a subset of any other list.", "In order to check if a list is a subset of another list, use two pointers technique to get a linear solution for this task. The total complexity will be O(n^2 * m) where n is the number of lists and m is the maximum number of elements in a list."], "metadata": {"canonical_parameter_names": ["favoriteCompanies"], "leetcode_dataset_entry_point": "Solution().peopleIndexes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:37+00:00", "tests_total": 79, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "hash-table", "string"]}, "language": "java", "interface": {"raw_signature": "public List peopleIndexes(List> favoriteCompanies) {", "container": "Solution", "callable": "peopleIndexes", "parameters": [{"name": "favoriteCompanies", "type": "List>"}], "return_type": "List", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1453, "task_id": "maximum-number-of-darts-inside-of-a-circular-dartboard", "difficulty": "Hard", "problem_description": "Alice is throwing n darts on a very large wall. You are given an array darts where darts[i] = [x_i, y_i] is the position of the i^th dart that Alice threw on the wall.\n\nBob knows the positions of the n darts on the wall. He wants to place a dartboard of radius r on the wall so that the maximum number of darts that Alice throws lie on the dartboard.\n\nGiven the integer r, return the maximum number of darts that can lie on the dartboard.\n\nExample 1:\n\nInput: darts = [[-2,0],[2,0],[0,2],[0,-2]], r = 2\nOutput: 4\nExplanation: Circle dartboard with center in (0,0) and radius = 2 contain all points.\n\nExample 2:\n\nInput: darts = [[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]], r = 5\nOutput: 5\nExplanation: Circle dartboard with center in (0,4) and radius = 5 contain all points except the point (7,8).\n\nConstraints:\n\n- 1 <= darts.length <= 100\n- darts[i].length == 2\n- -10^4 <= x_i, y_i <= 10^4\n- All the darts are unique\n- 1 <= r <= 5000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(darts = [[100, 100], [-100, -100], [0, 0]],r = 150) == 3\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3]],r = 1) == 3\n assert candidate(darts = [[-3, 0], [3, 0], [2, 6], [5, 4], [0, 9], [7, 8]],r = 5) == 5\n assert candidate(darts = [[-10000, 10000], [10000, -10000]],r = 5000) == 1\n assert candidate(darts = [[-1, -1], [1, 1], [-1, 1], [1, -1]],r = 2) == 4\n assert candidate(darts = [[-2, 2], [-3, 3], [-1, 1], [0, 0]],r = 2) == 3\n assert candidate(darts = [[1, 1], [2, 2], [3, 3]],r = 1) == 2\n assert candidate(darts = [[0, 0], [1, 1], [1.4, 1.4]],r = 1) == 3\n assert candidate(darts = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]],r = 2) == 3\n assert candidate(darts = [[0, 0], [10000, 0], [0, 10000], [10000, 10000]],r = 5000) == 2\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4]],r = 2) == 3\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]],r = 1) == 3\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4]],r = 1) == 2\n assert candidate(darts = [[1000, -1000], [-1000, 1000], [0, 0]],r = 1500) == 3\n assert candidate(darts = [[-5, 0], [5, 0], [0, 5], [0, -5]],r = 5) == 4\n assert candidate(darts = [[0, 0], [10, 0], [0, 10], [10, 10]],r = 7) == 2\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4]],r = 1) == 3\n assert candidate(darts = [[-5, -5], [5, 5], [-5, 5], [5, -5]],r = 7) == 2\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4]],r = 3) == 4\n assert candidate(darts = [[-1, 0], [0, 1], [1, 0], [0, -1]],r = 1) == 4\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0]],r = 1) == 3\n assert candidate(darts = [[0, 0], [1, 1], [1, -1], [-1, 1], [-1, -1]],r = 2) == 5\n assert candidate(darts = [[10, 10], [11, 11], [12, 12], [13, 13], [14, 14]],r = 1) == 2\n assert candidate(darts = [[-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2]],r = 1) == 2\n assert candidate(darts = [[0, 0], [0, 1], [1, 0], [1, 1]],r = 1) == 4\n assert candidate(darts = [[0, 0], [1, 0], [0, 1]],r = 1) == 3\n assert candidate(darts = [[-2, 0], [2, 0], [0, 2], [0, -2]],r = 2) == 4\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5]],r = 1) == 2\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],r = 1) == 2\n assert candidate(darts = [[-5000, 0], [5000, 0], [0, -5000], [0, 5000], [2500, 2500]],r = 5000) == 5\n assert candidate(darts = [[-2, -2], [-2, 0], [-2, 2], [0, -2], [0, 0], [0, 2], [2, -2], [2, 0], [2, 2]],r = 2) == 5\n assert candidate(darts = [[-200, 200], [-100, 100], [-50, 50], [0, 0], [50, -50], [100, -100], [200, -200], [50, 150], [150, 50], [-150, -50], [-50, -150]],r = 150) == 7\n assert candidate(darts = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10]],r = 5) == 2\n assert candidate(darts = [[-10000, 10000], [10000, -10000], [0, 0], [5000, 5000], [-5000, -5000]],r = 5000) == 2\n assert candidate(darts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],r = 5) == 4\n assert candidate(darts = [[-1, 0], [1, 0], [0, -1], [0, 1], [0.5, 0.5], [-0.5, -0.5], [0.5, -0.5], [-0.5, 0.5]],r = 1) == 8\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]],r = 2) == 5\n assert candidate(darts = [[-2, 2], [-2, -2], [2, 2], [2, -2], [0, 0], [0, 4], [4, 0], [4, 4]],r = 4) == 7\n assert candidate(darts = [[100, 100], [200, 200], [150, 150], [50, 50], [300, 300]],r = 150) == 4\n assert candidate(darts = [[1, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]],r = 5) == 4\n assert candidate(darts = [[1, 1], [1, 3], [3, 1], [3, 3], [5, 5], [5, 7], [7, 5], [7, 7], [9, 9], [9, 11]],r = 2.83) == 5\n assert candidate(darts = [[0, 0], [10, 0], [20, 0], [30, 0], [40, 0], [50, 0], [60, 0], [70, 0], [80, 0], [90, 0]],r = 10) == 3\n assert candidate(darts = [[-1000, -1000], [1000, 1000], [1000, -1000], [-1000, 1000], [0, 0]],r = 1414) == 3\n assert candidate(darts = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000], [1100, 1200], [1300, 1400], [1500, 1600], [1700, 1800], [1900, 2000]],r = 500) == 4\n assert candidate(darts = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700]],r = 150) == 3\n assert candidate(darts = [[0, 0], [5000, 0], [0, 5000], [5000, 5000], [2500, 2500]],r = 3000) == 3\n assert candidate(darts = [[-10, -10], [-9, -9], [-8, -8], [-7, -7], [-6, -6], [-5, -5], [-4, -4], [-3, -3], [-2, -2], [-1, -1]],r = 4) == 6\n assert candidate(darts = [[-1000, -1000], [-1000, 1000], [1000, -1000], [1000, 1000], [0, 0]],r = 1500) == 5\n assert candidate(darts = [[-500, -500], [-250, -250], [0, 0], [250, 250], [500, 500], [-500, 500], [500, -500]],r = 500) == 4\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]],r = 4) == 9\n assert candidate(darts = [[0, 0], [0, 2], [2, 0], [2, 2], [1, 1], [1, 3], [3, 1], [3, 3]],r = 2) == 7\n assert candidate(darts = [[0, 0], [100, 0], [200, 0], [300, 0], [400, 0], [500, 0], [600, 0], [700, 0], [800, 0], [900, 0]],r = 150) == 4\n assert candidate(darts = [[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]],r = 5) == 5\n assert candidate(darts = [[0, 0], [10, 0], [5, 5]],r = 10) == 3\n assert candidate(darts = [[100, 100], [200, 100], [100, 200], [200, 200], [150, 150], [125, 125], [175, 175]],r = 50) == 4\n assert candidate(darts = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],r = 2) == 3\n assert candidate(darts = [[0, 0], [50, 0], [100, 0], [150, 0], [200, 0], [250, 0], [300, 0], [350, 0], [400, 0], [450, 0], [500, 0]],r = 200) == 9\n assert candidate(darts = [[100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [100, 200], [200, 300]],r = 100) == 5\n assert candidate(darts = [[1000, 1000], [2000, 2000], [3000, 3000], [4000, 4000], [5000, 5000]],r = 5000) == 5\n assert candidate(darts = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],r = 1) == 2\n assert candidate(darts = [[0, 0], [1, 0], [0, 1], [1, 1], [0.5, 0.5]],r = 1) == 5\n assert candidate(darts = [[-1, -1], [-1, 1], [1, -1], [1, 1], [0, 0]],r = 1) == 3\n assert candidate(darts = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],r = 2) == 3\n assert candidate(darts = [[0, 0], [10, 0], [20, 0], [30, 0], [40, 0]],r = 10) == 3\n assert candidate(darts = [[-2000, -2000], [-1000, -1000], [0, 0], [1000, 1000], [2000, 2000], [1000, 0], [0, 1000]],r = 1414) == 4\n assert candidate(darts = [[-5000, -5000], [-4000, -4000], [-4500, -4500], [-3000, -3000], [-5500, -5500]],r = 1000) == 3\n assert candidate(darts = [[-1, -1], [0, -1], [1, -1], [-1, 0], [0, 0], [1, 0], [-1, 1], [0, 1], [1, 1]],r = 1) == 5\n assert candidate(darts = [[-10, -10], [-5, -5], [0, 0], [5, 5], [10, 10]],r = 8) == 3\n assert candidate(darts = [[-100, -100], [-100, 100], [100, -100], [100, 100], [0, 0]],r = 150) == 5\n assert candidate(darts = [[-1, -2], [-2, -4], [-3, -6], [-4, -8], [-5, -10], [-6, -12], [-7, -14]],r = 3) == 3\n assert candidate(darts = [[-1000, 0], [0, -1000], [1000, 0], [0, 1000], [500, 500], [-500, 500], [500, -500], [-500, -500]],r = 1000) == 8\n assert candidate(darts = [[-1000, -1000], [-1000, 1000], [1000, 1000], [1000, -1000], [0, 0], [500, 500]],r = 1000) == 4\n assert candidate(darts = [[-10, 0], [0, -10], [10, 0], [0, 10], [0, 0], [5, 5], [-5, -5], [-5, 5], [5, -5]],r = 15) == 9\n assert candidate(darts = [[-10, -10], [-10, 0], [-10, 10], [0, -10], [0, 0], [0, 10], [10, -10], [10, 0], [10, 10]],r = 15) == 9\n assert candidate(darts = [[-10, 0], [10, 0], [0, -10], [0, 10], [5, 5], [-5, -5]],r = 10) == 6\n assert candidate(darts = [[10, 10], [10, 20], [20, 10], [20, 20], [15, 15], [0, 0]],r = 10) == 5\n assert candidate(darts = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90]],r = 50) == 8\n assert candidate(darts = [[0, 0], [0, 100], [0, 200], [0, 300], [0, 400], [0, 500], [0, 600], [0, 700], [0, 800], [0, 900]],r = 150) == 4\n assert candidate(darts = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],r = 15) == 3\n assert candidate(darts = [[10, 10], [10, 20], [20, 10], [20, 20], [30, 30], [40, 40], [50, 50]],r = 15) == 5\n assert candidate(darts = [[-2000, -2000], [-2000, 2000], [2000, -2000], [2000, 2000], [0, 0]],r = 2500) == 3\n assert candidate(darts = [[-5000, 0], [5000, 0], [0, 5000], [0, -5000]],r = 5000) == 4\n assert candidate(darts = [[-2, -2], [-2, 2], [2, -2], [2, 2], [0, 0], [-1, 1], [1, -1], [-1, -1], [1, 1]],r = 3) == 9\n assert candidate(darts = [[1, 1], [1, 5], [5, 5], [5, 1], [3, 3], [2, 2], [4, 4], [2, 3], [3, 2], [4, 3], [3, 4]],r = 2) == 8\n assert candidate(darts = [[-500, 0], [-400, 0], [-300, 0], [-200, 0], [-100, 0], [0, 0], [100, 0], [200, 0], [300, 0], [400, 0]],r = 100) == 3\n assert candidate(darts = [[-10, 10], [10, -10], [-10, -10], [10, 10], [0, 0]],r = 20) == 5\n assert candidate(darts = [[1000, 1000], [1500, 1000], [1000, 1500], [1500, 1500], [2500, 2500]],r = 1000) == 4\n assert candidate(darts = [[-1000, 1000], [-500, 500], [0, 0], [500, -500], [1000, -1000]],r = 1500) == 5\n assert candidate(darts = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]],r = 150) == 3\n assert candidate(darts = [[5, 5], [10, 5], [15, 5], [20, 5], [25, 5], [5, 10], [10, 10], [15, 10], [20, 10], [25, 10]],r = 5) == 4\n assert candidate(darts = [[-20, 20], [-20, -20], [20, 20], [20, -20], [0, 0], [0, 40], [40, 0], [40, 40], [50, 50]],r = 50) == 9\n assert candidate(darts = [[1, 1], [2, 1], [3, 1], [4, 1], [1, 2], [2, 2], [3, 2], [4, 2], [1, 3], [2, 3], [3, 3], [4, 3]],r = 1) == 5\n assert candidate(darts = [[1000, 1000], [2000, 2000], [3000, 3000], [4000, 4000], [5000, 5000]],r = 1000) == 2\n assert candidate(darts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]],r = 5) == 4\n assert candidate(darts = [[-5000, 5000], [5000, -5000], [-5000, -5000], [5000, 5000], [0, 0]],r = 5000) == 3\n assert candidate(darts = [[0, 0], [100, 0], [200, 0], [300, 0], [400, 0], [500, 0], [600, 0], [700, 0], [800, 0], [900, 0]],r = 100) == 3\n assert candidate(darts = [[1000, -1000], [1500, -1000], [2000, -1000], [1000, -1500], [1000, -2000]],r = 500) == 3\n assert candidate(darts = [[1000, 1000], [1001, 1001], [1002, 1002], [1003, 1003], [1004, 1004], [1005, 1005], [1006, 1006], [1007, 1007], [1008, 1008], [1009, 1009]],r = 1) == 2\n assert candidate(darts = [[1, 1], [1, 4], [4, 1], [4, 4], [2, 2], [3, 3]],r = 2) == 4\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],r = 3) == 7\n assert candidate(darts = [[-5000, -5000], [5000, 5000], [0, 0], [1, 1]],r = 5000) == 3\n assert candidate(darts = [[0, 0], [0, 10], [10, 0], [10, 10]],r = 7) == 2\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],r = 2) == 3\n assert candidate(darts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],r = 1) == 1\n assert candidate(darts = [[-1000, 1000], [1000, -1000], [500, 500], [-500, -500]],r = 1000) == 3\n assert candidate(darts = [[1, 1], [1, 3], [3, 1], [3, 3], [2, 2], [4, 4], [4, 5], [5, 4]],r = 1) == 3\n assert candidate(darts = [[-5000, -5000], [-4000, -4000], [-3000, -3000], [-2000, -2000], [-1000, -1000]],r = 1000) == 2\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0]],r = 2) == 5\n assert candidate(darts = [[-5, -5], [0, 0], [5, 5], [10, 10], [15, 15]],r = 7) == 2\n assert candidate(darts = [[-100, -100], [100, 100], [-100, 100], [100, -100], [0, 0]],r = 150) == 5\n assert candidate(darts = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],r = 1) == 5\n assert candidate(darts = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700]],r = 100) == 2\n assert candidate(darts = [[100, 100], [101, 100], [102, 102], [102, 101], [101, 102]],r = 2) == 5\n assert candidate(darts = [[0, 0], [5, 0], [5, 5], [0, 5], [2.5, 2.5]],r = 3) == 3\n assert candidate(darts = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3]],r = 1) == 4\n assert candidate(darts = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14]],r = 3) == 3\n assert candidate(darts = [[-1000, 1000], [-900, 1100], [-800, 1200], [-700, 1300], [-600, 1400], [-500, 1500], [-400, 1600], [-300, 1700]],r = 200) == 3\n assert candidate(darts = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]],r = 50) == 4\n assert candidate(darts = [[-2000, -2000], [2000, 2000], [0, 0], [1000, -1000], [-1000, 1000]],r = 2500) == 4\n assert candidate(darts = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600]],r = 100) == 2\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],r = 1.5) == 3\n assert candidate(darts = [[500, 500], [500, 600], [600, 500], [600, 600], [300, 300], [300, 400], [400, 300], [400, 400]],r = 141) == 4\n assert candidate(darts = [[-5, 5], [5, 5], [5, -5], [-5, -5], [0, 0]],r = 5) == 3\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],r = 2) == 3\n assert candidate(darts = [[1, 1], [2, 1], [1, 2], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],r = 1) == 4\n assert candidate(darts = [[0, 0], [0, 1], [1, 0], [1, 1], [0, 2], [1, 2], [2, 0], [2, 1], [2, 2]],r = 1.5) == 9\n", "comparison": "exact"}, "public_tests": ["[[-2,0],[2,0],[0,2],[0,-2]]\n2", "[[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]]\n5"], "hints": ["If there is an optimal solution, you can always move the circle so that two points lie on the boundary of the circle.", "When the radius is fixed, you can find either 0 or 1 or 2 circles that pass two given points at the same time.", "Loop for each pair of points and find the center of the circle, after that count the number of points inside the circle."], "metadata": {"canonical_parameter_names": ["darts", "r"], "leetcode_dataset_entry_point": "Solution().numPoints", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:39+00:00", "tests_total": 130, "tests_dropped": 4, "flags": ["has_images"], "topic_tags": ["array", "math", "geometry"]}, "language": "java", "interface": {"raw_signature": "public int numPoints(int[][] darts, int r) {", "container": "Solution", "callable": "numPoints", "parameters": [{"name": "darts", "type": "int[][]"}, {"name": "r", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1453, "task_id": "maximum-number-of-darts-inside-of-a-circular-dartboard", "difficulty": "Hard", "problem_description": "Alice is throwing n darts on a very large wall. You are given an array darts where darts[i] = [x_i, y_i] is the position of the i^th dart that Alice threw on the wall.\n\nBob knows the positions of the n darts on the wall. He wants to place a dartboard of radius r on the wall so that the maximum number of darts that Alice throws lie on the dartboard.\n\nGiven the integer r, return the maximum number of darts that can lie on the dartboard.\n\nExample 1:\n\nInput: darts = [[-2,0],[2,0],[0,2],[0,-2]], r = 2\nOutput: 4\nExplanation: Circle dartboard with center in (0,0) and radius = 2 contain all points.\n\nExample 2:\n\nInput: darts = [[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]], r = 5\nOutput: 5\nExplanation: Circle dartboard with center in (0,4) and radius = 5 contain all points except the point (7,8).\n\nConstraints:\n\n- 1 <= darts.length <= 100\n- darts[i].length == 2\n- -10^4 <= x_i, y_i <= 10^4\n- All the darts are unique\n- 1 <= r <= 5000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(darts = [[100, 100], [-100, -100], [0, 0]],r = 150) == 3\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3]],r = 1) == 3\n assert candidate(darts = [[-3, 0], [3, 0], [2, 6], [5, 4], [0, 9], [7, 8]],r = 5) == 5\n assert candidate(darts = [[-10000, 10000], [10000, -10000]],r = 5000) == 1\n assert candidate(darts = [[-1, -1], [1, 1], [-1, 1], [1, -1]],r = 2) == 4\n assert candidate(darts = [[-2, 2], [-3, 3], [-1, 1], [0, 0]],r = 2) == 3\n assert candidate(darts = [[1, 1], [2, 2], [3, 3]],r = 1) == 2\n assert candidate(darts = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]],r = 2) == 3\n assert candidate(darts = [[0, 0], [10000, 0], [0, 10000], [10000, 10000]],r = 5000) == 2\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4]],r = 2) == 3\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]],r = 1) == 3\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4]],r = 1) == 2\n assert candidate(darts = [[1000, -1000], [-1000, 1000], [0, 0]],r = 1500) == 3\n assert candidate(darts = [[-5, 0], [5, 0], [0, 5], [0, -5]],r = 5) == 4\n assert candidate(darts = [[0, 0], [10, 0], [0, 10], [10, 10]],r = 7) == 2\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4]],r = 1) == 3\n assert candidate(darts = [[-5, -5], [5, 5], [-5, 5], [5, -5]],r = 7) == 2\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4]],r = 3) == 4\n assert candidate(darts = [[-1, 0], [0, 1], [1, 0], [0, -1]],r = 1) == 4\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0]],r = 1) == 3\n assert candidate(darts = [[0, 0], [1, 1], [1, -1], [-1, 1], [-1, -1]],r = 2) == 5\n assert candidate(darts = [[10, 10], [11, 11], [12, 12], [13, 13], [14, 14]],r = 1) == 2\n assert candidate(darts = [[-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2]],r = 1) == 2\n assert candidate(darts = [[0, 0], [0, 1], [1, 0], [1, 1]],r = 1) == 4\n assert candidate(darts = [[0, 0], [1, 0], [0, 1]],r = 1) == 3\n assert candidate(darts = [[-2, 0], [2, 0], [0, 2], [0, -2]],r = 2) == 4\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5]],r = 1) == 2\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],r = 1) == 2\n assert candidate(darts = [[-5000, 0], [5000, 0], [0, -5000], [0, 5000], [2500, 2500]],r = 5000) == 5\n assert candidate(darts = [[-2, -2], [-2, 0], [-2, 2], [0, -2], [0, 0], [0, 2], [2, -2], [2, 0], [2, 2]],r = 2) == 5\n assert candidate(darts = [[-200, 200], [-100, 100], [-50, 50], [0, 0], [50, -50], [100, -100], [200, -200], [50, 150], [150, 50], [-150, -50], [-50, -150]],r = 150) == 7\n assert candidate(darts = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10]],r = 5) == 2\n assert candidate(darts = [[-10000, 10000], [10000, -10000], [0, 0], [5000, 5000], [-5000, -5000]],r = 5000) == 2\n assert candidate(darts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],r = 5) == 4\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]],r = 2) == 5\n assert candidate(darts = [[-2, 2], [-2, -2], [2, 2], [2, -2], [0, 0], [0, 4], [4, 0], [4, 4]],r = 4) == 7\n assert candidate(darts = [[100, 100], [200, 200], [150, 150], [50, 50], [300, 300]],r = 150) == 4\n assert candidate(darts = [[1, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]],r = 5) == 4\n assert candidate(darts = [[0, 0], [10, 0], [20, 0], [30, 0], [40, 0], [50, 0], [60, 0], [70, 0], [80, 0], [90, 0]],r = 10) == 3\n assert candidate(darts = [[-1000, -1000], [1000, 1000], [1000, -1000], [-1000, 1000], [0, 0]],r = 1414) == 3\n assert candidate(darts = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000], [1100, 1200], [1300, 1400], [1500, 1600], [1700, 1800], [1900, 2000]],r = 500) == 4\n assert candidate(darts = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700]],r = 150) == 3\n assert candidate(darts = [[0, 0], [5000, 0], [0, 5000], [5000, 5000], [2500, 2500]],r = 3000) == 3\n assert candidate(darts = [[-10, -10], [-9, -9], [-8, -8], [-7, -7], [-6, -6], [-5, -5], [-4, -4], [-3, -3], [-2, -2], [-1, -1]],r = 4) == 6\n assert candidate(darts = [[-1000, -1000], [-1000, 1000], [1000, -1000], [1000, 1000], [0, 0]],r = 1500) == 5\n assert candidate(darts = [[-500, -500], [-250, -250], [0, 0], [250, 250], [500, 500], [-500, 500], [500, -500]],r = 500) == 4\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]],r = 4) == 9\n assert candidate(darts = [[0, 0], [0, 2], [2, 0], [2, 2], [1, 1], [1, 3], [3, 1], [3, 3]],r = 2) == 7\n assert candidate(darts = [[0, 0], [100, 0], [200, 0], [300, 0], [400, 0], [500, 0], [600, 0], [700, 0], [800, 0], [900, 0]],r = 150) == 4\n assert candidate(darts = [[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]],r = 5) == 5\n assert candidate(darts = [[0, 0], [10, 0], [5, 5]],r = 10) == 3\n assert candidate(darts = [[100, 100], [200, 100], [100, 200], [200, 200], [150, 150], [125, 125], [175, 175]],r = 50) == 4\n assert candidate(darts = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],r = 2) == 3\n assert candidate(darts = [[0, 0], [50, 0], [100, 0], [150, 0], [200, 0], [250, 0], [300, 0], [350, 0], [400, 0], [450, 0], [500, 0]],r = 200) == 9\n assert candidate(darts = [[100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [100, 200], [200, 300]],r = 100) == 5\n assert candidate(darts = [[1000, 1000], [2000, 2000], [3000, 3000], [4000, 4000], [5000, 5000]],r = 5000) == 5\n assert candidate(darts = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],r = 1) == 2\n assert candidate(darts = [[-1, -1], [-1, 1], [1, -1], [1, 1], [0, 0]],r = 1) == 3\n assert candidate(darts = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],r = 2) == 3\n assert candidate(darts = [[0, 0], [10, 0], [20, 0], [30, 0], [40, 0]],r = 10) == 3\n assert candidate(darts = [[-2000, -2000], [-1000, -1000], [0, 0], [1000, 1000], [2000, 2000], [1000, 0], [0, 1000]],r = 1414) == 4\n assert candidate(darts = [[-5000, -5000], [-4000, -4000], [-4500, -4500], [-3000, -3000], [-5500, -5500]],r = 1000) == 3\n assert candidate(darts = [[-1, -1], [0, -1], [1, -1], [-1, 0], [0, 0], [1, 0], [-1, 1], [0, 1], [1, 1]],r = 1) == 5\n assert candidate(darts = [[-10, -10], [-5, -5], [0, 0], [5, 5], [10, 10]],r = 8) == 3\n assert candidate(darts = [[-100, -100], [-100, 100], [100, -100], [100, 100], [0, 0]],r = 150) == 5\n assert candidate(darts = [[-1, -2], [-2, -4], [-3, -6], [-4, -8], [-5, -10], [-6, -12], [-7, -14]],r = 3) == 3\n assert candidate(darts = [[-1000, 0], [0, -1000], [1000, 0], [0, 1000], [500, 500], [-500, 500], [500, -500], [-500, -500]],r = 1000) == 8\n assert candidate(darts = [[-1000, -1000], [-1000, 1000], [1000, 1000], [1000, -1000], [0, 0], [500, 500]],r = 1000) == 4\n assert candidate(darts = [[-10, 0], [0, -10], [10, 0], [0, 10], [0, 0], [5, 5], [-5, -5], [-5, 5], [5, -5]],r = 15) == 9\n assert candidate(darts = [[-10, -10], [-10, 0], [-10, 10], [0, -10], [0, 0], [0, 10], [10, -10], [10, 0], [10, 10]],r = 15) == 9\n assert candidate(darts = [[-10, 0], [10, 0], [0, -10], [0, 10], [5, 5], [-5, -5]],r = 10) == 6\n assert candidate(darts = [[10, 10], [10, 20], [20, 10], [20, 20], [15, 15], [0, 0]],r = 10) == 5\n assert candidate(darts = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90]],r = 50) == 8\n assert candidate(darts = [[0, 0], [0, 100], [0, 200], [0, 300], [0, 400], [0, 500], [0, 600], [0, 700], [0, 800], [0, 900]],r = 150) == 4\n assert candidate(darts = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],r = 15) == 3\n assert candidate(darts = [[10, 10], [10, 20], [20, 10], [20, 20], [30, 30], [40, 40], [50, 50]],r = 15) == 5\n assert candidate(darts = [[-2000, -2000], [-2000, 2000], [2000, -2000], [2000, 2000], [0, 0]],r = 2500) == 3\n assert candidate(darts = [[-5000, 0], [5000, 0], [0, 5000], [0, -5000]],r = 5000) == 4\n assert candidate(darts = [[-2, -2], [-2, 2], [2, -2], [2, 2], [0, 0], [-1, 1], [1, -1], [-1, -1], [1, 1]],r = 3) == 9\n assert candidate(darts = [[1, 1], [1, 5], [5, 5], [5, 1], [3, 3], [2, 2], [4, 4], [2, 3], [3, 2], [4, 3], [3, 4]],r = 2) == 8\n assert candidate(darts = [[-500, 0], [-400, 0], [-300, 0], [-200, 0], [-100, 0], [0, 0], [100, 0], [200, 0], [300, 0], [400, 0]],r = 100) == 3\n assert candidate(darts = [[-10, 10], [10, -10], [-10, -10], [10, 10], [0, 0]],r = 20) == 5\n assert candidate(darts = [[1000, 1000], [1500, 1000], [1000, 1500], [1500, 1500], [2500, 2500]],r = 1000) == 4\n assert candidate(darts = [[-1000, 1000], [-500, 500], [0, 0], [500, -500], [1000, -1000]],r = 1500) == 5\n assert candidate(darts = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]],r = 150) == 3\n assert candidate(darts = [[5, 5], [10, 5], [15, 5], [20, 5], [25, 5], [5, 10], [10, 10], [15, 10], [20, 10], [25, 10]],r = 5) == 4\n assert candidate(darts = [[-20, 20], [-20, -20], [20, 20], [20, -20], [0, 0], [0, 40], [40, 0], [40, 40], [50, 50]],r = 50) == 9\n assert candidate(darts = [[1, 1], [2, 1], [3, 1], [4, 1], [1, 2], [2, 2], [3, 2], [4, 2], [1, 3], [2, 3], [3, 3], [4, 3]],r = 1) == 5\n assert candidate(darts = [[1000, 1000], [2000, 2000], [3000, 3000], [4000, 4000], [5000, 5000]],r = 1000) == 2\n assert candidate(darts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]],r = 5) == 4\n assert candidate(darts = [[-5000, 5000], [5000, -5000], [-5000, -5000], [5000, 5000], [0, 0]],r = 5000) == 3\n assert candidate(darts = [[0, 0], [100, 0], [200, 0], [300, 0], [400, 0], [500, 0], [600, 0], [700, 0], [800, 0], [900, 0]],r = 100) == 3\n assert candidate(darts = [[1000, -1000], [1500, -1000], [2000, -1000], [1000, -1500], [1000, -2000]],r = 500) == 3\n assert candidate(darts = [[1000, 1000], [1001, 1001], [1002, 1002], [1003, 1003], [1004, 1004], [1005, 1005], [1006, 1006], [1007, 1007], [1008, 1008], [1009, 1009]],r = 1) == 2\n assert candidate(darts = [[1, 1], [1, 4], [4, 1], [4, 4], [2, 2], [3, 3]],r = 2) == 4\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],r = 3) == 7\n assert candidate(darts = [[-5000, -5000], [5000, 5000], [0, 0], [1, 1]],r = 5000) == 3\n assert candidate(darts = [[0, 0], [0, 10], [10, 0], [10, 10]],r = 7) == 2\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],r = 2) == 3\n assert candidate(darts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],r = 1) == 1\n assert candidate(darts = [[-1000, 1000], [1000, -1000], [500, 500], [-500, -500]],r = 1000) == 3\n assert candidate(darts = [[1, 1], [1, 3], [3, 1], [3, 3], [2, 2], [4, 4], [4, 5], [5, 4]],r = 1) == 3\n assert candidate(darts = [[-5000, -5000], [-4000, -4000], [-3000, -3000], [-2000, -2000], [-1000, -1000]],r = 1000) == 2\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0]],r = 2) == 5\n assert candidate(darts = [[-5, -5], [0, 0], [5, 5], [10, 10], [15, 15]],r = 7) == 2\n assert candidate(darts = [[-100, -100], [100, 100], [-100, 100], [100, -100], [0, 0]],r = 150) == 5\n assert candidate(darts = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],r = 1) == 5\n assert candidate(darts = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700]],r = 100) == 2\n assert candidate(darts = [[100, 100], [101, 100], [102, 102], [102, 101], [101, 102]],r = 2) == 5\n assert candidate(darts = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3]],r = 1) == 4\n assert candidate(darts = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14]],r = 3) == 3\n assert candidate(darts = [[-1000, 1000], [-900, 1100], [-800, 1200], [-700, 1300], [-600, 1400], [-500, 1500], [-400, 1600], [-300, 1700]],r = 200) == 3\n assert candidate(darts = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]],r = 50) == 4\n assert candidate(darts = [[-2000, -2000], [2000, 2000], [0, 0], [1000, -1000], [-1000, 1000]],r = 2500) == 4\n assert candidate(darts = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600]],r = 100) == 2\n assert candidate(darts = [[500, 500], [500, 600], [600, 500], [600, 600], [300, 300], [300, 400], [400, 300], [400, 400]],r = 141) == 4\n assert candidate(darts = [[-5, 5], [5, 5], [5, -5], [-5, -5], [0, 0]],r = 5) == 3\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],r = 2) == 3\n assert candidate(darts = [[1, 1], [2, 1], [1, 2], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],r = 1) == 4\n", "comparison": "exact"}, "public_tests": ["[[-2,0],[2,0],[0,2],[0,-2]]\n2", "[[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]]\n5"], "hints": ["If there is an optimal solution, you can always move the circle so that two points lie on the boundary of the circle.", "When the radius is fixed, you can find either 0 or 1 or 2 circles that pass two given points at the same time.", "Loop for each pair of points and find the center of the circle, after that count the number of points inside the circle."], "metadata": {"canonical_parameter_names": ["darts", "r"], "leetcode_dataset_entry_point": "Solution().numPoints", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:39+00:00", "tests_total": 130, "tests_dropped": 11, "flags": ["has_images"], "topic_tags": ["array", "math", "geometry"]}, "language": "java", "interface": {"raw_signature": "public int numPoints(int[][] darts, int r) {", "container": "Solution", "callable": "numPoints", "parameters": [{"name": "darts", "type": "int[][]"}, {"name": "r", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1455, "task_id": "check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence", "difficulty": "Easy", "problem_description": "Given a sentence that consists of some words separated by a single space, and a searchWord, check if searchWord is a prefix of any word in sentence.\n\nReturn the index of the word in sentence (1-indexed) where searchWord is a prefix of this word. If searchWord is a prefix of more than one word, return the index of the first word (minimum index). If there is no such word return -1.\n\nA prefix of a string s is any leading contiguous substring of s.\n\nExample 1:\n\nInput: sentence = \"i love eating burger\", searchWord = \"burg\"\nOutput: 4\nExplanation: \"burg\" is prefix of \"burger\" which is the 4th word in the sentence.\n\nExample 2:\n\nInput: sentence = \"this problem is an easy problem\", searchWord = \"pro\"\nOutput: 2\nExplanation: \"pro\" is prefix of \"problem\" which is the 2nd and the 6th word in the sentence, but we return 2 as it's the minimal index.\n\nExample 3:\n\nInput: sentence = \"i am tired\", searchWord = \"you\"\nOutput: -1\nExplanation: \"you\" is not a prefix of any word in the sentence.\n\nConstraints:\n\n- 1 <= sentence.length <= 100\n- 1 <= searchWord.length <= 10\n- sentence consists of lowercase English letters and spaces.\n- searchWord consists of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentence = \"a ab abc abd\",searchWord = \"a\") == 1\n assert candidate(sentence = \"abcde fghij klmno\",searchWord = \"mnop\") == -1\n assert candidate(sentence = \"find prefix quickly\",searchWord = \"qui\") == 3\n assert candidate(sentence = \"prefix test\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"prefix test\",searchWord = \"testprefix\") == -1\n assert candidate(sentence = \"hello world\",searchWord = \"he\") == 1\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"aaaa\") == 4\n assert candidate(sentence = \"coding in python is fun\",searchWord = \"py\") == 3\n assert candidate(sentence = \"i love eating burger\",searchWord = \"burg\") == 4\n assert candidate(sentence = \"prefix prefixation prefixed pre\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"i am tired\",searchWord = \"you\") == -1\n assert candidate(sentence = \"example test case\",searchWord = \"exa\") == 1\n assert candidate(sentence = \"start end\",searchWord = \"sta\") == 1\n assert candidate(sentence = \"no match here\",searchWord = \"none\") == -1\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"qui\") == 2\n assert candidate(sentence = \"coding in python\",searchWord = \"py\") == 3\n assert candidate(sentence = \"prefix test\",searchWord = \"fix\") == -1\n assert candidate(sentence = \"prefix test\",searchWord = \"test\") == 2\n assert candidate(sentence = \"abc def ghi\",searchWord = \"def\") == 2\n assert candidate(sentence = \"no matches here\",searchWord = \"match\") == 2\n assert candidate(sentence = \"all words unique\",searchWord = \"word\") == 2\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"aaa\") == 3\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"a\") == 1\n assert candidate(sentence = \"unique words only here\",searchWord = \"word\") == 2\n assert candidate(sentence = \"prefix prefix prefix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"one two three\",searchWord = \"four\") == -1\n assert candidate(sentence = \"prefix test\",searchWord = \"tes\") == 2\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"aa\") == 2\n assert candidate(sentence = \"make america great again\",searchWord = \"am\") == 2\n assert candidate(sentence = \"prefix is the start\",searchWord = \"start\") == 4\n assert candidate(sentence = \"a b c d e f g\",searchWord = \"g\") == 7\n assert candidate(sentence = \"find the prefix\",searchWord = \"pre\") == 3\n assert candidate(sentence = \"this problem is an easy problem\",searchWord = \"pro\") == 2\n assert candidate(sentence = \"last word match\",searchWord = \"match\") == 3\n assert candidate(sentence = \"prefix test\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"a ab abc abcd abcde\",searchWord = \"abc\") == 3\n assert candidate(sentence = \"mississippi missouri\",searchWord = \"miss\") == 1\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"aaaaa\") == -1\n assert candidate(sentence = \"multiple matches match matcher matching\",searchWord = \"mat\") == 2\n assert candidate(sentence = \"introduction to the world of algorithms and datastructures\",searchWord = \"data\") == 8\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyz\",searchWord = \"abc\") == 1\n assert candidate(sentence = \"mississippi missouri missing\",searchWord = \"miss\") == 1\n assert candidate(sentence = \"prefix is present in the prefix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"unique words only unique\",searchWord = \"uniq\") == 1\n assert candidate(sentence = \"look at these examples\",searchWord = \"these\") == 3\n assert candidate(sentence = \"unique words only here\",searchWord = \"only\") == 3\n assert candidate(sentence = \"prefix suffix prefixsuffix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"testing for edge cases with different words\",searchWord = \"dif\") == 6\n assert candidate(sentence = \"one two three four five six seven eight nine ten\",searchWord = \"ten\") == 10\n assert candidate(sentence = \"aaaaa aaaaa aaaaa aaaaa\",searchWord = \"aaaa\") == 1\n assert candidate(sentence = \"algorithm datastructure code compiler bytecode\",searchWord = \"byte\") == 5\n assert candidate(sentence = \"finding exact match in the sentence\",searchWord = \"exac\") == 2\n assert candidate(sentence = \"hello world from the other side\",searchWord = \"from\") == 3\n assert candidate(sentence = \"singleword\",searchWord = \"single\") == 1\n assert candidate(sentence = \"this is a very very long sentence to test the code properly\",searchWord = \"very\") == 4\n assert candidate(sentence = \"multiple occurrences of the same prefix\",searchWord = \"same\") == 5\n assert candidate(sentence = \"prefix testing with prefix prefix prefix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"overlap overlapping overlapped overlap\",searchWord = \"overl\") == 1\n assert candidate(sentence = \"find the correct index\",searchWord = \"cor\") == 3\n assert candidate(sentence = \"python programming is powerful\",searchWord = \"pro\") == 2\n assert candidate(sentence = \"boundary conditions need testing\",searchWord = \"test\") == 4\n assert candidate(sentence = \"algorithm and data structures are important\",searchWord = \"and\") == 2\n assert candidate(sentence = \"substring matching problem\",searchWord = \"match\") == 2\n assert candidate(sentence = \"pneumonoultramicroscopicsilicovolcanoconiosis pneumonoultramicroscopicsilicovolcanoconiosis\",searchWord = \"pneumono\") == 1\n assert candidate(sentence = \"hello world hello universe\",searchWord = \"he\") == 1\n assert candidate(sentence = \"algorithm datastructure programming language compiler\",searchWord = \"pro\") == 3\n assert candidate(sentence = \"uniquewordsinthesentence\",searchWord = \"words\") == -1\n assert candidate(sentence = \"prefixprefixprefixprefix\",searchWord = \"pref\") == 1\n assert candidate(sentence = \"quick brown fox jumps over the lazy dog\",searchWord = \"qu\") == 1\n assert candidate(sentence = \"continuous conversation connection component\",searchWord = \"con\") == 1\n assert candidate(sentence = \"small big medium small\",searchWord = \"sm\") == 1\n assert candidate(sentence = \"algorithm and data structures\",searchWord = \"alg\") == 1\n assert candidate(sentence = \"prefix problem prefixing prefixer\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"short longword reallylongword evenlongerword\",searchWord = \"long\") == 2\n assert candidate(sentence = \"binary search quicksort mergesort heapsort\",searchWord = \"sort\") == -1\n assert candidate(sentence = \"one two three four five six seven eight nine ten\",searchWord = \"fi\") == 5\n assert candidate(sentence = \"aaaaa aaaa aa a\",searchWord = \"a\") == 1\n assert candidate(sentence = \"prefix search in a list of words\",searchWord = \"sea\") == 2\n assert candidate(sentence = \"testing boundary conditions\",searchWord = \"boundary\") == 2\n assert candidate(sentence = \"testing edgecases with variouslengthwords\",searchWord = \"var\") == 4\n assert candidate(sentence = \"very very long sentence with many words to test the function\",searchWord = \"very\") == 1\n assert candidate(sentence = \"repeated repeated repeated\",searchWord = \"rep\") == 1\n assert candidate(sentence = \"searching for a longprefixword\",searchWord = \"longprefix\") == 4\n assert candidate(sentence = \"an apple a day keeps the doctor away\",searchWord = \"app\") == 2\n assert candidate(sentence = \"sun moon stars planets galaxies blackholes nebulas\",searchWord = \"black\") == 6\n assert candidate(sentence = \"every good boy does fine great boys deserve fine gifts\",searchWord = \"fi\") == 5\n assert candidate(sentence = \"abcdefgh abcdefghij abcdefghijk abcdefghijkl\",searchWord = \"abcdefg\") == 1\n assert candidate(sentence = \"another example to check\",searchWord = \"to\") == 3\n assert candidate(sentence = \"this is a simple test to check for prefix matching\",searchWord = \"tes\") == 5\n assert candidate(sentence = \"searching for exact prefix\",searchWord = \"sea\") == 1\n assert candidate(sentence = \"prefix prefix prefix prefix\",searchWord = \"pref\") == 1\n assert candidate(sentence = \"this is a simple sentence for testing\",searchWord = \"simple\") == 4\n assert candidate(sentence = \"hiddenprefixword is here\",searchWord = \"hidden\") == 1\n assert candidate(sentence = \"banana apple banana apple banana\",searchWord = \"ba\") == 1\n assert candidate(sentence = \"words with multiple spaces\",searchWord = \"mul\") == 3\n assert candidate(sentence = \"algorithm datastructure programming language\",searchWord = \"pro\") == 3\n assert candidate(sentence = \"prefixprefixprefixprefixprefix\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"prefix prefix prefix prefix prefix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"complex problem requiring careful thought\",searchWord = \"com\") == 1\n assert candidate(sentence = \"random words with no match\",searchWord = \"nomatch\") == -1\n assert candidate(sentence = \"python programming py pyth pytho\",searchWord = \"py\") == 1\n assert candidate(sentence = \"abcd efgh ijkl mnop qrst uvwx yz\",searchWord = \"yz\") == 7\n assert candidate(sentence = \"findingprefixsinthesentence\",searchWord = \"finding\") == 1\n assert candidate(sentence = \"prefix matching is important for search engines\",searchWord = \"search\") == 6\n assert candidate(sentence = \"abracadabra abracadabra abracadabra\",searchWord = \"abra\") == 1\n assert candidate(sentence = \"nonmatchingprefix prefix\",searchWord = \"non\") == 1\n assert candidate(sentence = \"finding the first occurrence firstness\",searchWord = \"fir\") == 3\n assert candidate(sentence = \"prefix matching problem prefixing preposition\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"none of these should match\",searchWord = \"non\") == 1\n assert candidate(sentence = \"prefix prefixing prefixation prefixed\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"multiple occurrences of a word word\",searchWord = \"word\") == 5\n assert candidate(sentence = \"all words are different\",searchWord = \"dif\") == 4\n assert candidate(sentence = \"prefixes are important in computer science\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"mismatch mismatching mismatches\",searchWord = \"mis\") == 1\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"do\") == 9\n assert candidate(sentence = \"xy xxy xxxy xxxxy xxxxyy xxxxyyy\",searchWord = \"xxxxy\") == 4\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"dog\") == 9\n assert candidate(sentence = \"repeated repeated repeated repeated\",searchWord = \"repeat\") == 1\n assert candidate(sentence = \"quick brown fox jumps over lazy dog\",searchWord = \"quic\") == 1\n assert candidate(sentence = \"prefixprefixprefix prefixprefix prefix pre prefixing\",searchWord = \"prefixp\") == 1\n assert candidate(sentence = \"ab ac ad ae af ag ah ai aj\",searchWord = \"a\") == 1\n assert candidate(sentence = \"this is a simple test case\",searchWord = \"sim\") == 4\n assert candidate(sentence = \"prefixprefix prefixprefixer prefixprefixing\",searchWord = \"prefixpre\") == 1\n assert candidate(sentence = \"unique words with no match\",searchWord = \"xyz\") == -1\n assert candidate(sentence = \"abracadabra abracadabra abracadabra\",searchWord = \"abrac\") == 1\n assert candidate(sentence = \"continuous integration and continuous delivery\",searchWord = \"cont\") == 1\n assert candidate(sentence = \"searching for the prefix within\",searchWord = \"with\") == 5\n assert candidate(sentence = \"consecutive words with same start\",searchWord = \"con\") == 1\n assert candidate(sentence = \"short long longer longest\",searchWord = \"long\") == 2\n assert candidate(sentence = \"consistent consistent consistency consistently\",searchWord = \"consist\") == 1\n assert candidate(sentence = \"a short simple sentence\",searchWord = \"shor\") == 2\n assert candidate(sentence = \"searching for a unique prefix\",searchWord = \"uniq\") == 4\n assert candidate(sentence = \"a quick brown fox jumps over the lazy dog\",searchWord = \"fox\") == 4\n assert candidate(sentence = \"programming is fun and educational\",searchWord = \"edu\") == 5\n assert candidate(sentence = \"finding the veryfirst occurrence\",searchWord = \"ver\") == 3\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"qu\") == 2\n assert candidate(sentence = \"prefix prefixing prefixed\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"boundary conditions are tricky\",searchWord = \"tri\") == 4\n assert candidate(sentence = \"complexity of the problem\",searchWord = \"com\") == 1\n assert candidate(sentence = \"a aa aaa aaaa aaaaa aaaaaa\",searchWord = \"aaaa\") == 4\n assert candidate(sentence = \"searching for a specific word\",searchWord = \"spec\") == 4\n assert candidate(sentence = \"multiple occurrences of the same prefix prefix prefix\",searchWord = \"pre\") == 6\n assert candidate(sentence = \"ab abc abcd abcde abcdef abcdefg abcdefgh abcdefghi abcdefghij\",searchWord = \"abcde\") == 4\n assert candidate(sentence = \"partial match is not allowed\",searchWord = \"parti\") == 1\n assert candidate(sentence = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",searchWord = \"z\") == 26\n assert candidate(sentence = \"one two three four five six seven eight nine ten\",searchWord = \"nine\") == 9\n assert candidate(sentence = \"prefixes prefixing prefix pre prefixed\",searchWord = \"pref\") == 1\n assert candidate(sentence = \"prefix prefixing prefixed pre prefixable\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"a a aa aa aaa\",searchWord = \"aaa\") == 5\n assert candidate(sentence = \"looking for a specific starting sequence\",searchWord = \"spe\") == 4\n assert candidate(sentence = \"algorithm data structure and algorithm\",searchWord = \"algo\") == 1\n assert candidate(sentence = \"overlapwording overlapword overlap\",searchWord = \"overlap\") == 1\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"the\") == 1\n assert candidate(sentence = \"prefix prefix prefix\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"prefix prefix prefix prefix\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"shorter is better\",searchWord = \"short\") == 1\n assert candidate(sentence = \"algorithms and data structures\",searchWord = \"and\") == 2\n assert candidate(sentence = \"interview question with multiple prefixes prefix\",searchWord = \"pre\") == 5\n assert candidate(sentence = \"banana bandana band breadth\",searchWord = \"ban\") == 1\n assert candidate(sentence = \"algorithms and data structures are fundamental\",searchWord = \"data\") == 3\n assert candidate(sentence = \"practice makes perfect in programming\",searchWord = \"per\") == 3\n assert candidate(sentence = \"verylongwordthatwilltesttheboundariesofthisfunction\",searchWord = \"verylong\") == 1\n assert candidate(sentence = \"longerprefix longerpre long pre\",searchWord = \"longerpre\") == 1\n assert candidate(sentence = \"this is a simple sentence with repeated words repeated words\",searchWord = \"repe\") == 7\n assert candidate(sentence = \"a quick brown fox jumps over the lazy dog\",searchWord = \"do\") == 9\n assert candidate(sentence = \"multiple occurrences of words words\",searchWord = \"words\") == 4\n assert candidate(sentence = \"double double double trouble\",searchWord = \"double\") == 1\n assert candidate(sentence = \"complicated complex complication\",searchWord = \"comp\") == 1\n assert candidate(sentence = \"banana bandana bandanna banana bandana\",searchWord = \"band\") == 2\n", "comparison": "exact"}, "public_tests": ["\"i love eating burger\"\n\"burg\"", "\"this problem is an easy problem\"\n\"pro\"", "\"i am tired\"\n\"you\""], "hints": ["First extract the words of the sentence.", "Check for each word if searchWord occurs at index 0, if so return the index of this word (1-indexed)", "If searchWord doesn't exist as a prefix of any word return the default value (-1)."], "metadata": {"canonical_parameter_names": ["sentence", "searchWord"], "leetcode_dataset_entry_point": "Solution().isPrefixOfWord", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:42+00:00", "tests_total": 172, "tests_dropped": 3, "flags": [], "topic_tags": ["two-pointers", "string", "string-matching"]}, "language": "java", "interface": {"raw_signature": "public int isPrefixOfWord(String sentence, String searchWord) {", "container": "Solution", "callable": "isPrefixOfWord", "parameters": [{"name": "sentence", "type": "String"}, {"name": "searchWord", "type": "String"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1456, "task_id": "maximum-number-of-vowels-in-a-substring-of-given-length", "difficulty": "Medium", "problem_description": "Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k.\n\nVowel letters in English are 'a', 'e', 'i', 'o', and 'u'.\n\nExample 1:\n\nInput: s = \"abciiidef\", k = 3\nOutput: 3\nExplanation: The substring \"iii\" contains 3 vowel letters.\n\nExample 2:\n\nInput: s = \"aeiou\", k = 2\nOutput: 2\nExplanation: Any substring of length 2 contains 2 vowels.\n\nExample 3:\n\nInput: s = \"leetcode\", k = 3\nOutput: 2\nExplanation: \"lee\", \"eet\" and \"ode\" contain 2 vowels.\n\nConstraints:\n\n- 1 <= s.length <= 10^5\n- s consists of lowercase English letters.\n- 1 <= k <= s.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aooiiieeec\",k = 6) == 6\n assert candidate(s = \"a\",k = 1) == 1\n assert candidate(s = \"happy\",k = 2) == 1\n assert candidate(s = \"rhythms\",k = 5) == 0\n assert candidate(s = \"fluffy\",k = 2) == 1\n assert candidate(s = \"leetcode\",k = 3) == 2\n assert candidate(s = \"aeiou\",k = 2) == 2\n assert candidate(s = \"beautiful\",k = 4) == 3\n assert candidate(s = \"rhythms\",k = 4) == 0\n assert candidate(s = \"bbbb\",k = 2) == 0\n assert candidate(s = \"aaaaaa\",k = 5) == 5\n assert candidate(s = \"abciiidef\",k = 3) == 3\n assert candidate(s = \"aabbccddeeff\",k = 4) == 2\n assert candidate(s = \"quartz\",k = 3) == 2\n assert candidate(s = \"uuuuuuuuuuuuuuuuuuuuuuuuuu\",k = 5) == 5\n assert candidate(s = \"eiuaooeiuaooeiuaooeiuaoo\",k = 8) == 8\n assert candidate(s = \"bcdfghjklmnpqrstvwxyz\",k = 3) == 0\n assert candidate(s = \"understanding\",k = 4) == 2\n assert candidate(s = \"abacabadabacaba\",k = 5) == 3\n assert candidate(s = \"aeiouaeiou\",k = 1) == 1\n assert candidate(s = \"bbbbbbaaaaa\",k = 5) == 5\n assert candidate(s = \"bbaeixixixixxxeiiixieeiix\",k = 15) == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 50) == 0\n assert candidate(s = \"uoieaouieaouieaouieaouieaouieao\",k = 15) == 15\n assert candidate(s = \"mississippi\",k = 4) == 2\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiou\",k = 20) == 20\n assert candidate(s = \"iouaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 50) == 50\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 12) == 4\n assert candidate(s = \"xyzvowelsabcdefg\",k = 5) == 2\n assert candidate(s = \"leetcodeisawesome\",k = 5) == 3\n assert candidate(s = \"lovelaceeinstein\",k = 7) == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 13) == 3\n assert candidate(s = \"thisisaverylongstringwithsomevowelsinside\",k = 20) == 8\n assert candidate(s = \"aaaaaaaabbbbbbbbcccccccc\",k = 12) == 8\n assert candidate(s = \"bbaeiooacaioiiceiue\",k = 11) == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 20) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 26) == 6\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiou\",k = 10) == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzz\",k = 20) == 0\n assert candidate(s = \"uvvwxyz\",k = 3) == 1\n assert candidate(s = \"abcdeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\",k = 15) == 15\n assert candidate(s = \"uoieaouieaouieaouieaouieaouiea\",k = 7) == 7\n assert candidate(s = \"mnoabcdeioufghijkl\",k = 7) == 4\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 15) == 4\n assert candidate(s = \"leetcodeisaverygoodplatform\",k = 10) == 6\n assert candidate(s = \"ababababab\",k = 5) == 3\n assert candidate(s = \"uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\",k = 30) == 30\n assert candidate(s = \"bcdafg\",k = 6) == 1\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaa\",k = 10) == 10\n assert candidate(s = \"bcdfghjklmnpqrstvwxyz\",k = 1) == 0\n assert candidate(s = \"thisisaverylongstringwithseveralvowelsinside\",k = 15) == 6\n assert candidate(s = \"aiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioiei\",k = 20) == 20\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\",k = 15) == 15\n assert candidate(s = \"uoieaouioeaouioeaouioe\",k = 12) == 12\n assert candidate(s = \"aeiouaeiouaeiouaeiou\",k = 7) == 7\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbc\",k = 7) == 0\n assert candidate(s = \"uqeiouqeiouqeiouqeiouqeiouqe\",k = 11) == 9\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 10) == 3\n assert candidate(s = \"qqqwwweee\",k = 4) == 3\n assert candidate(s = \"bbaeixoubb\",k = 5) == 4\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 26) == 5\n assert candidate(s = \"aeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeiioooooooouuuuuuuuuuuaaaaaaaa\",k = 25) == 25\n assert candidate(s = \"bvflkqmbvkjgnqmfqlqjflvngqnvfkvnqjvfbvmqjbfvmlkjbfnvqjgbfnvqjbngfjkqnvbmfkqjbgfnjkbv\",k = 10) == 0\n assert candidate(s = \"vowelsarebeautiful\",k = 10) == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 15) == 0\n assert candidate(s = \"bcbcbcbcbcbaaaaaa\",k = 10) == 6\n assert candidate(s = \"aeiaaioaaaaeiiiiiiooooaauuaeiu\",k = 15) == 15\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyz\",k = 8) == 0\n assert candidate(s = \"thisisaverylongstringwithlotsofvowelsandconsonants\",k = 18) == 7\n assert candidate(s = \"environmentally\",k = 10) == 4\n assert candidate(s = \"leetcodeisacommunityforcoders\",k = 8) == 5\n assert candidate(s = \"leetcodeisfun\",k = 7) == 4\n assert candidate(s = \"leetcodeisawesome\",k = 7) == 4\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\",k = 10) == 0\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiii\",k = 5) == 3\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbc\",k = 3) == 0\n assert candidate(s = \"uoieaooooieau\",k = 7) == 7\n assert candidate(s = \"abecidofugihanukleomnonuopqrstuvwxyz\",k = 20) == 10\n assert candidate(s = \"aeiaaioaaaaeiiiiouuuu\",k = 12) == 12\n", "comparison": "exact"}, "public_tests": ["\"abciiidef\"\n3", "\"aeiou\"\n2", "\"leetcode\"\n3"], "hints": ["Keep a window of size k and maintain the number of vowels in it.", "Keep moving the window and update the number of vowels while moving. Answer is max number of vowels of any window."], "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().maxVowels", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:44+00:00", "tests_total": 80, "tests_dropped": 1, "flags": [], "topic_tags": ["string", "sliding-window"]}, "language": "java", "interface": {"raw_signature": "public int maxVowels(String s, int k) {", "container": "Solution", "callable": "maxVowels", "parameters": [{"name": "s", "type": "String"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1458, "task_id": "max-dot-product-of-two-subsequences", "difficulty": "Hard", "problem_description": "Given two arrays nums1 and nums2.\n\nReturn the maximum dot product between non-empty subsequences of nums1 and nums2 with the same length.\n\nA subsequence of an array is a new array which is formed from the original array by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, [2,3,5] is a subsequence of [1,2,3,4,5] while [1,5,3] is not).\n\nExample 1:\n\nInput: nums1 = [2,1,-2,5], nums2 = [3,0,-6]\nOutput: 18\nExplanation: Take subsequence [2,-2] from nums1 and subsequence [3,-6] from nums2.\nTheir dot product is (2*3 + (-2)*(-6)) = 18.\n\nExample 2:\n\nInput: nums1 = [3,-2], nums2 = [2,-6,7]\nOutput: 21\nExplanation: Take subsequence [3] from nums1 and subsequence [7] from nums2.\nTheir dot product is (3*7) = 21.\n\nExample 3:\n\nInput: nums1 = [-1,-1], nums2 = [1,1]\nOutput: -1\nExplanation: Take subsequence [-1] from nums1 and subsequence [1] from nums2.\nTheir dot product is -1.\n\nConstraints:\n\n- 1 <= nums1.length, nums2.length <= 500\n- -1000 <= nums1[i], nums2[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1]) == 2\n assert candidate(nums1 = [2, 1, -2, 5],nums2 = [3, 0, -6]) == 18\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == 46\n assert candidate(nums1 = [1, 3, -5, 4],nums2 = [-2, -4, 0, 3]) == 32\n assert candidate(nums1 = [-1, -1],nums2 = [1, 1]) == -1\n assert candidate(nums1 = [1000, -1000],nums2 = [-1000, 1000]) == 1000000\n assert candidate(nums1 = [-1000, 1000],nums2 = [-1000, 1000]) == 2000000\n assert candidate(nums1 = [5, 4, -3],nums2 = [4, -1, -2]) == 26\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 46\n assert candidate(nums1 = [1000],nums2 = [-1000]) == -1000000\n assert candidate(nums1 = [0, 1, 2, 3, 4],nums2 = [5, 6, 7, 8, 9]) == 80\n assert candidate(nums1 = [-1000],nums2 = [1000]) == -1000000\n assert candidate(nums1 = [3, -2],nums2 = [2, -6, 7]) == 21\n assert candidate(nums1 = [1, 2, 3, 4],nums2 = [-3, -2, -1, 0]) == 0\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == 46\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 46\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1]) == 12\n assert candidate(nums1 = [1, 2, 3],nums2 = [-5, -4, -3]) == -3\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == 32\n assert candidate(nums1 = [5, 4, 3],nums2 = [1, 2, 3]) == 22\n assert candidate(nums1 = [5, 5, 2, 1, 5],nums2 = [1, 2, 4, 2, 5]) == 59\n assert candidate(nums1 = [1],nums2 = [1]) == 1\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [-1, -2, -3, -4, -5]) == 46\n assert candidate(nums1 = [0, 0, 0],nums2 = [0, 0, 0]) == 0\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums1 = [999, -999, 999, -999, 999],nums2 = [-999, 999, -999, 999, -999]) == 3992004\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums1 = [5, 2, -4, 7, -8],nums2 = [3, -1, 6, -3, 2]) == 85\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [1, 2, 3, 4]) == 0\n assert candidate(nums1 = [1, -1, 1, -1, 1, -1],nums2 = [-1, 1, -1, 1, -1, 1]) == 5\n assert candidate(nums1 = [1, -1, 1, -1, 1],nums2 = [1, -1, 1, -1, 1]) == 5\n assert candidate(nums1 = [5, 3, -4, 2, 1],nums2 = [-2, 6, 3, -5, 4]) == 67\n assert candidate(nums1 = [5, 3, -2, 4],nums2 = [1, 2, 3, 4, 5]) == 47\n assert candidate(nums1 = [100, -100, 200, -200, 300],nums2 = [1, -1, 2, -2, 3]) == 1900\n assert candidate(nums1 = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],nums2 = [-5, 5, -4, 4, -3, 3, -2, 2, -1, 1]) == 90\n assert candidate(nums1 = [100, -100, 200, -200],nums2 = [-100, 100, -200, 200]) == 70000\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [-1, -2, -3, -4, -5]) == -10\n assert candidate(nums1 = [-10, -20, -30, -40, -50],nums2 = [1, 2, 3, 4, 5]) == -10\n assert candidate(nums1 = [999, 1000, -999, -1000],nums2 = [-999, 999, -1000, 1000]) == 1999000\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == -100\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [-10, -20, -30, -40, -50]) == -100\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 320\n assert candidate(nums1 = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],nums2 = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 81\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5]) == 125\n assert candidate(nums1 = [5, -10, 15, -20, 25],nums2 = [-5, 10, -15, 20]) == 1000\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 46\n assert candidate(nums1 = [100, -100, 200, -200, 300, -300],nums2 = [10, -10, 20, -20, 30, -30]) == 28000\n assert candidate(nums1 = [0, 1, -1, 2, -2, 3, -3],nums2 = [3, -3, 2, -2, 1, -1, 0]) == 24\n assert candidate(nums1 = [5, -3, 10, 2, -7],nums2 = [8, 4, -2, 6, 1]) == 108\n assert candidate(nums1 = [-500, -400, -300, -200, -100],nums2 = [100, 200, 300, 400, 500]) == -10000\n assert candidate(nums1 = [-5, -3, -2, -4],nums2 = [-1, -2, -3, -4, -5]) == 47\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1029\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 74\n assert candidate(nums1 = [100, 0, 200, 0, 300, 0, 400, 0, 500, 0],nums2 = [0, 500, 0, 400, 0, 300, 0, 200, 0, 100]) == 460000\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [1, 3, 5, 7, 9]) == 190\n assert candidate(nums1 = [10, -10, 20, -20, 30],nums2 = [30, -30, 20, -20, 10]) == 1800\n assert candidate(nums1 = [-1, 0, 1, 0, -1],nums2 = [-1, 0, 1, 0, -1]) == 3\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [-1, -2, -3, -4, -5]) == -1\n assert candidate(nums1 = [5, -3, 8, -1, 7],nums2 = [-2, 4, 1, -5, 3]) == 64\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3]) == 56\n assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [5, 4, 3, 2, 1]) == -1\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [-100, -200, -300, -400, -500]) == -10000\n assert candidate(nums1 = [1000, 900, 800, 700, 600],nums2 = [10, 20, 30, 40, 50]) == 114000\n assert candidate(nums1 = [5, -3, 2, 1, 6],nums2 = [-1, 2, -3, 4, 5]) == 57\n assert candidate(nums1 = [1, 2, 3],nums2 = [100, 200, 300, 400, 500]) == 2600\n assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [-5, -4, -3, -2, -1]) == 46\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == -1\n assert candidate(nums1 = [1, -2, 3, -4, 5],nums2 = [-5, 4, -3, 2, -1]) == 44\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 385\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [1, 2, 3]) == 2600\n assert candidate(nums1 = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],nums2 = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 38500\n assert candidate(nums1 = [999, -999, 888, -888, 777, -777],nums2 = [-666, 666, -555, 555, -444, 444, -333, 333]) == 2710620\n assert candidate(nums1 = [1, -1, 1, -1, 1],nums2 = [-1, 1, -1, 1, -1]) == 4\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == 4750\n assert candidate(nums1 = [1000, 999, 998, 997, 996],nums2 = [1, 2, 3, 4, 5]) == 14960\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [100, 200, 300]) == 2200\n assert candidate(nums1 = [100, -100, 200, -200],nums2 = [300, -300, 400, -400]) == 220000\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6, 7, 8, 9, 10, 11, 12]) == 68\n assert candidate(nums1 = [1, 2, 3],nums2 = [-1, -2, -3, 4, 5]) == 23\n assert candidate(nums1 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums1 = [5, -3, 8, 1],nums2 = [-7, 4, 6, -2]) == 69\n assert candidate(nums1 = [1, 3, -5, 7, -9],nums2 = [-9, 7, -5, 3, 1]) == 139\n assert candidate(nums1 = [1, 3, -5, 7, -9, 11],nums2 = [11, -9, 7, -5, 3, -1]) == 235\n assert candidate(nums1 = [1, 3, -5, 7, -9],nums2 = [-2, 4, -6, 8, -10]) == 188\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 20, 10]) == 1200\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3850\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 190\n assert candidate(nums1 = [-5, -5, -5, -5, -5],nums2 = [-5, -5, -5, -5, -5]) == 125\n assert candidate(nums1 = [1, 0, -1, 0, 1],nums2 = [0, 1, 0, -1, 0]) == 2\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100]) == 460000\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5]) == 55\n assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums1 = [-50, -40, -30, -20, -10],nums2 = [-10, -20, -30, -40, -50]) == 4600\n assert candidate(nums1 = [1, -1, 2, -2, 3, -3],nums2 = [-1, 1, -2, 2, -3, 3]) == 22\n assert candidate(nums1 = [100, 200, 300],nums2 = [1, 2, 3, 4, 5]) == 2600\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [0, 0, 0, 0]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [-1, -1, -1, -1, -1]) == -1\n assert candidate(nums1 = [1, -1, 2, -2, 3, -3],nums2 = [3, -3, 2, -2, 1, -1]) == 24\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [-1, -2, -3, -4, -5]) == -1\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [10]) == 1000\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [-50, -40, -30, -20, -10]) == -100\n assert candidate(nums1 = [-10, -20, -30, -40, -50],nums2 = [10, 20, 30, 40, 50]) == -100\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10]) == 4600\n assert candidate(nums1 = [1, 0, -1, 0, 1],nums2 = [1, 0, -1, 0, 1]) == 3\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13],nums2 = [2, 4, 6, 8, 10, 12, 14]) == 504\n assert candidate(nums1 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [-1, -1, -1, -1, -1]) == -1\n assert candidate(nums1 = [-1, 0, 1, -2, 0, 2],nums2 = [2, 0, -2, 0, 1, -1]) == 8\n", "comparison": "exact"}, "public_tests": ["[2,1,-2,5]\n[3,0,-6]", "[3,-2]\n[2,-6,7]", "[-1,-1]\n[1,1]"], "hints": ["Use dynamic programming, define DP[i][j] as the maximum dot product of two subsequences starting in the position i of nums1 and position j of nums2."], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().maxDotProduct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:20:46+00:00", "tests_total": 109, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming", "longest-common-subsequence"]}, "language": "java", "interface": {"raw_signature": "public int maxDotProduct(int[] nums1, int[] nums2) {", "container": "Solution", "callable": "maxDotProduct", "parameters": [{"name": "nums1", "type": "int[]"}, {"name": "nums2", "type": "int[]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} @@ -462,7 +462,7 @@ {"question_id": 1475, "task_id": "final-prices-with-a-special-discount-in-a-shop", "difficulty": "Easy", "problem_description": "You are given an integer array prices where prices[i] is the price of the i^th item in a shop.\n\nThere is a special discount for items in the shop. If you buy the i^th item, then you will receive a discount equivalent to prices[j] where j is the minimum index such that j > i and prices[j] <= prices[i]. Otherwise, you will not receive any discount at all.\n\nReturn an integer array answer where answer[i] is the final price you will pay for the i^th item of the shop, considering the special discount.\n\nExample 1:\n\nInput: prices = [8,4,6,2,3]\nOutput: [4,2,4,2,3]\nExplanation:\nFor item 0 with price[0]=8 you will receive a discount equivalent to prices[1]=4, therefore, the final price you will pay is 8 - 4 = 4.\nFor item 1 with price[1]=4 you will receive a discount equivalent to prices[3]=2, therefore, the final price you will pay is 4 - 2 = 2.\nFor item 2 with price[2]=6 you will receive a discount equivalent to prices[3]=2, therefore, the final price you will pay is 6 - 2 = 4.\nFor items 3 and 4 you will not receive any discount at all.\n\nExample 2:\n\nInput: prices = [1,2,3,4,5]\nOutput: [1,2,3,4,5]\nExplanation: In this case, for all items, you will not receive any discount at all.\n\nExample 3:\n\nInput: prices = [10,1,1,6]\nOutput: [9,0,1,6]\n\nConstraints:\n\n- 1 <= prices.length <= 500\n- 1 <= prices[i] <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(prices = [5, 5, 5, 5, 5]) == [0, 0, 0, 0, 5]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [8, 4, 6, 2, 3]) == [4, 2, 4, 2, 3]\n assert candidate(prices = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(prices = [9, 8, 7, 6, 5]) == [1, 1, 1, 1, 5]\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(prices = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == [1, 3, 5, 7, 9, 11, 13, 15, 17]\n assert candidate(prices = [60, 70, 80, 90, 100]) == [60, 70, 80, 90, 100]\n assert candidate(prices = [10, 10, 10, 10, 10, 10]) == [0, 0, 0, 0, 0, 10]\n assert candidate(prices = [5, 1, 4, 2, 3]) == [4, 1, 2, 2, 3]\n assert candidate(prices = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(prices = [100, 50, 25, 12, 6, 3, 1]) == [50, 25, 13, 6, 3, 2, 1]\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(prices = [10, 1, 1, 6]) == [9, 0, 1, 6]\n assert candidate(prices = [1, 2, 3, 2, 1]) == [0, 0, 1, 1, 1]\n assert candidate(prices = [5, 1, 3, 4, 6, 2]) == [4, 1, 1, 2, 4, 2]\n assert candidate(prices = [3, 3, 3, 2, 2, 1]) == [0, 0, 1, 0, 1, 1]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [100, 90, 80, 70, 60]) == [10, 10, 10, 10, 60]\n assert candidate(prices = [100, 200, 300, 200, 100]) == [0, 0, 100, 100, 100]\n assert candidate(prices = [1, 1, 1, 1, 1]) == [0, 0, 0, 0, 1]\n assert candidate(prices = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(prices = [2, 3, 1]) == [1, 2, 1]\n assert candidate(prices = [100, 50, 50, 100, 50, 25, 25, 100]) == [50, 0, 0, 50, 25, 0, 25, 100]\n assert candidate(prices = [10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10]) == [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 5, 10]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5]\n assert candidate(prices = [1, 2, 3, 2, 3, 4, 5, 4, 5, 6]) == [1, 0, 1, 2, 3, 0, 1, 4, 5, 6]\n assert candidate(prices = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2]\n assert candidate(prices = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(prices = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]\n assert candidate(prices = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == [1, 98, 2, 96, 3, 94, 4, 92, 5, 96]\n assert candidate(prices = [10, 10, 10, 10, 10, 10, 10, 10]) == [0, 0, 0, 0, 0, 0, 0, 10]\n assert candidate(prices = [10, 5, 15, 5, 20, 10, 25, 15, 30, 20]) == [5, 0, 10, 5, 10, 10, 10, 15, 10, 20]\n assert candidate(prices = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4]) == [1, 1, 1, 1, 1, 1, 1, 2, 3, 4]\n assert candidate(prices = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [0, 9, 0, 9, 0, 9, 0, 9, 1, 10]\n assert candidate(prices = [7, 5, 6, 4, 3, 2, 1, 8, 9, 10]) == [2, 1, 2, 1, 1, 1, 1, 8, 9, 10]\n assert candidate(prices = [2, 3, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1]) == [0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1]\n assert candidate(prices = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4, 1, 2, 3, 4, 5]\n assert candidate(prices = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [0, 8, 1, 6, 2, 4, 3, 2, 4, 5, 1, 8, 2, 6, 3, 4, 4, 2, 5, 6]\n assert candidate(prices = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1000]\n assert candidate(prices = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]\n assert candidate(prices = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == [0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5]\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(prices = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == [500, 250, 125, 63, 31, 16, 8, 4, 2, 1]\n assert candidate(prices = [10, 20, 30, 40, 50, 40, 30, 20, 10]) == [0, 0, 0, 0, 10, 10, 10, 10, 10]\n assert candidate(prices = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [0, 10, 0, 10, 0, 10, 0, 10, 10, 20]\n assert candidate(prices = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == [0, 0, 1, 1, 0, 0, 1, 1, 1]\n assert candidate(prices = [30, 20, 10, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == [10, 10, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10]\n assert candidate(prices = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == [1, 1, 1, 1, 1, 2, 3, 4, 5]\n assert candidate(prices = [8, 6, 7, 6, 5, 4, 3, 2, 1]) == [2, 0, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [300, 200, 100, 50, 25, 12, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [100, 100, 50, 25, 13, 6, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(prices = [8, 4, 6, 2, 3, 8, 4, 6, 2, 3]) == [4, 2, 4, 0, 1, 4, 2, 4, 2, 3]\n assert candidate(prices = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 1, 10]\n assert candidate(prices = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == [1, 1, 2, 1, 3, 1, 4, 1, 5, 7]\n assert candidate(prices = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]\n assert candidate(prices = [15, 10, 5, 10, 15, 5, 10, 15, 20, 10]) == [5, 5, 0, 5, 10, 5, 0, 5, 10, 10]\n assert candidate(prices = [10, 20, 30, 10, 20, 30, 10, 20, 30]) == [0, 10, 20, 0, 10, 20, 10, 20, 30]\n assert candidate(prices = [3, 6, 5, 1, 8, 7, 9, 2, 4, 10]) == [2, 1, 4, 1, 1, 5, 7, 2, 4, 10]\n assert candidate(prices = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == [0, 1, 0, 1, 0, 1, 0, 1, 2, 3]\n assert candidate(prices = [8, 5, 7, 6, 4, 5, 3, 2, 1]) == [3, 1, 1, 2, 1, 2, 1, 1, 1]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(prices = [50, 20, 30, 10, 20, 30, 40, 50, 60, 70]) == [30, 10, 20, 10, 20, 30, 40, 50, 60, 70]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5]\n assert candidate(prices = [500, 100, 200, 300, 400, 500, 600, 700, 800, 900]) == [400, 100, 200, 300, 400, 500, 600, 700, 800, 900]\n assert candidate(prices = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5]) == [99, 1, 198, 2, 297, 3, 396, 4, 495, 5]\n assert candidate(prices = [999, 1000, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == [1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 980]\n assert candidate(prices = [100, 200, 150, 250, 300, 220, 180, 160, 170]) == [100, 50, 150, 30, 80, 40, 20, 160, 170]\n assert candidate(prices = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(prices = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(prices = [5, 10, 15, 20, 15, 10, 5, 10, 15, 20, 15, 10, 5]) == [0, 0, 0, 5, 5, 5, 0, 0, 0, 5, 5, 5, 5]\n assert candidate(prices = [3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5]) == [0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 5]\n assert candidate(prices = [5, 15, 25, 10, 20, 5, 30, 25, 40, 10]) == [0, 5, 15, 5, 15, 5, 5, 15, 30, 10]\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 1]\n assert candidate(prices = [8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5]\n assert candidate(prices = [1000, 1000, 1000, 1000, 1000]) == [0, 0, 0, 0, 1000]\n assert candidate(prices = [5, 1, 4, 3, 2, 6, 7, 8, 10, 9]) == [4, 1, 1, 1, 2, 6, 7, 8, 1, 9]\n assert candidate(prices = [8, 4, 6, 2, 3, 5, 7, 1, 9, 10]) == [4, 2, 4, 1, 2, 4, 6, 1, 9, 10]\n assert candidate(prices = [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1]) == [100, 100, 100, 100, 50, 25, 13, 6, 3, 2, 1]\n assert candidate(prices = [250, 200, 150, 100, 50, 100, 150, 200, 250, 300]) == [50, 50, 50, 50, 50, 100, 150, 200, 250, 300]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6]\n assert candidate(prices = [1, 10, 1, 10, 1, 10, 1, 10]) == [0, 9, 0, 9, 0, 9, 1, 10]\n assert candidate(prices = [30, 25, 20, 15, 10, 5, 10, 15, 20, 25]) == [5, 5, 5, 5, 5, 5, 10, 15, 20, 25]\n assert candidate(prices = [4, 3, 2, 1, 2, 3, 4, 5, 6, 7]) == [1, 1, 1, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(prices = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == [1, 1, 1, 1, 0, 1, 2, 3, 4, 5]\n assert candidate(prices = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n assert candidate(prices = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 50]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(prices = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10]) == [0, 5, 0, 5, 0, 5, 0, 5, 5, 10]\n assert candidate(prices = [1, 2, 2, 1, 1, 2, 2, 1, 1]) == [0, 0, 1, 0, 0, 0, 1, 0, 1]\n assert candidate(prices = [100, 50, 25, 200, 100, 50, 25, 200]) == [50, 25, 0, 100, 50, 25, 25, 200]\n assert candidate(prices = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == [1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8]\n assert candidate(prices = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 2, 3]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 10]\n assert candidate(prices = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(prices = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [0, 9, 0, 9, 0, 9, 0, 9, 1, 10]\n assert candidate(prices = [3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 2]\n assert candidate(prices = [1, 3, 2, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == [0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5]) == [0, 0, 0, 0, 10, 10, 10, 10, 5, 5]\n assert candidate(prices = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5]\n assert candidate(prices = [50, 40, 30, 20, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == [10, 10, 10, 10, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]\n assert candidate(prices = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == [4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4]\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(prices = [50, 25, 75, 100, 50, 75, 100, 125]) == [25, 25, 25, 50, 50, 75, 100, 125]\n assert candidate(prices = [100, 200, 300, 400, 500, 400, 300, 200, 100]) == [0, 0, 0, 0, 100, 100, 100, 100, 100]\n", "comparison": "exact"}, "public_tests": ["[8,4,6,2,3]", "[1,2,3,4,5]", "[10,1,1,6]"], "hints": ["Use brute force: For the ith item in the shop with a loop find the first position j satisfying the conditions and apply the discount, otherwise, the discount is 0."], "metadata": {"canonical_parameter_names": ["prices"], "leetcode_dataset_entry_point": "Solution().finalPrices", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:18+00:00", "tests_total": 117, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "stack", "monotonic-stack"]}, "language": "java", "interface": {"raw_signature": "public int[] finalPrices(int[] prices) {", "container": "Solution", "callable": "finalPrices", "parameters": [{"name": "prices", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1477, "task_id": "find-two-non-overlapping-sub-arrays-each-with-target-sum", "difficulty": "Medium", "problem_description": "You are given an array of integers arr and an integer target.\n\nYou have to find two non-overlapping sub-arrays of arr each with a sum equal target. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is minimum.\n\nReturn the minimum sum of the lengths of the two required sub-arrays, or return -1 if you cannot find such two sub-arrays.\n\nExample 1:\n\nInput: arr = [3,2,2,4,3], target = 3\nOutput: 2\nExplanation: Only two sub-arrays have sum = 3 ([3] and [3]). The sum of their lengths is 2.\n\nExample 2:\n\nInput: arr = [7,3,4,7], target = 7\nOutput: 2\nExplanation: Although we have three non-overlapping sub-arrays of sum = 7 ([7], [3,4] and [7]), but we will choose the first and third sub-arrays as the sum of their lengths is 2.\n\nExample 3:\n\nInput: arr = [4,3,2,6,2,3,4], target = 6\nOutput: -1\nExplanation: We have only one sub-array of sum = 6.\n\nConstraints:\n\n- 1 <= arr.length <= 10^5\n- 1 <= arr[i] <= 1000\n- 1 <= target <= 10^8\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [5, 5, 5, 5, 5],target = 10) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 5\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 6) == 6\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3],target = 6) == 5\n assert candidate(arr = [1, 2, 3, 4, 5],target = 9) == -1\n assert candidate(arr = [3, 2, 2, 4, 3],target = 3) == 2\n assert candidate(arr = [5, 5, 4, 4, 5],target = 9) == 4\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 4) == 4\n assert candidate(arr = [1000, 1000, 1000],target = 2000) == -1\n assert candidate(arr = [7, 3, 4, 7],target = 7) == 2\n assert candidate(arr = [1000, 1000, 1000, 1000, 1000],target = 2000) == 4\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3],target = 3) == 2\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],target = 3) == 4\n assert candidate(arr = [1000, 1000, 1000, 1000, 1000],target = 5000) == -1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 4\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 6\n assert candidate(arr = [1, 2, 3, 4, 5],target = 10) == -1\n assert candidate(arr = [10, 20, 30, 40, 50],target = 60) == -1\n assert candidate(arr = [1, 4, 4, 4, 4, 4, 4, 4, 4, 1],target = 8) == 4\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 6\n assert candidate(arr = [4, 3, 2, 6, 2, 3, 4],target = 6) == -1\n assert candidate(arr = [10, 20, 30, 40, 50],target = 90) == -1\n assert candidate(arr = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1],target = 1000) == 4\n assert candidate(arr = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],target = 50) == 4\n assert candidate(arr = [3, 1, 2, 4, 3, 2, 1, 3, 4, 2, 1, 3, 5, 2, 1, 3, 4, 2, 1, 3],target = 6) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],target = 30) == 4\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 15) == 3\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 500) == -1\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = 300) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],target = 100) == 13\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 20) == 8\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 20) == -1\n assert candidate(arr = [1, 3, 2, 1, 5, 2, 3, 1, 4, 2, 3, 1, 5, 2, 3, 1, 4, 2, 3, 1],target = 6) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 15) == 3\n assert candidate(arr = [1, 4, 2, 3, 5, 7, 9, 11, 13, 15],target = 15) == 4\n assert candidate(arr = [5, 1, 3, 5, 10, 7, 4, 9, 2, 8, 6],target = 15) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 4\n assert candidate(arr = [1, 4, 4, 1, 1, 2, 3, 5, 3, 2, 3, 4, 1],target = 8) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 10\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 30) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 10) == 20\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 20) == 8\n assert candidate(arr = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50],target = 60) == 4\n assert candidate(arr = [9, 1, 2, 3, 9, 4, 5, 9, 6, 7, 8, 9],target = 9) == 2\n assert candidate(arr = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],target = 6) == 6\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 6\n assert candidate(arr = [5, 2, 3, 4, 1, 5, 2, 3, 4, 1, 5, 2, 3, 4, 1, 5, 2, 3, 4, 1],target = 10) == 6\n assert candidate(arr = [5, 1, 3, 5, 2, 1, 2, 3, 5, 2, 1, 2, 3, 5, 2, 1, 2, 3, 5, 2, 1, 2, 3, 5, 2, 1, 2, 3],target = 9) == -1\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 1500) == 5\n assert candidate(arr = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 4\n assert candidate(arr = [7, 8, 3, 4, 7, 6, 5, 4, 3, 2, 1],target = 15) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 20) == -1\n assert candidate(arr = [7, 1, 3, 1, 2, 1, 3, 1, 7, 1, 3, 1, 2, 1, 3, 1, 7, 1, 3, 1, 2, 1, 3, 1, 7, 1, 3, 1],target = 10) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 10\n assert candidate(arr = [5, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 21) == 5\n assert candidate(arr = [1, 4, 2, 3, 5, 2, 3, 1, 4, 2, 3, 5, 2, 3, 1, 4, 2, 3, 5, 2, 3, 1, 4, 2, 3, 5, 2, 3, 1, 4, 2, 3],target = 8) == 4\n assert candidate(arr = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500],target = 600) == 5\n assert candidate(arr = [2, 3, 2, 2, 3, 3, 2, 2, 2, 3],target = 6) == 5\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 1500) == 5\n assert candidate(arr = [100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300],target = 600) == 6\n assert candidate(arr = [5, 1, 3, 5, 2, 4, 8, 6, 3, 7],target = 10) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 30) == 8\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 5\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 10) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 10\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 5\n assert candidate(arr = [3, 2, 2, 4, 3, 3, 2, 2, 4, 3, 3, 2, 2, 4, 3, 3, 2, 2, 4, 3, 3, 2, 2, 4, 3, 3, 2, 2, 4, 3],target = 5) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 4\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 400) == -1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 20) == 40\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 100) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 9) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 20) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 4\n assert candidate(arr = [5, 1, 3, 5, 10, 7, 4, 9, 2, 8],target = 15) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],target = 3) == 3\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],target = 4) == 6\n assert candidate(arr = [100, 200, 100, 300, 200, 400, 300, 500, 400, 600],target = 300) == 2\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 5\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 10) == 4\n assert candidate(arr = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500],target = 1000) == 8\n", "comparison": "exact"}, "public_tests": ["[3,2,2,4,3]\n3", "[7,3,4,7]\n7", "[4,3,2,6,2,3,4]\n6"], "hints": ["Let's create two arrays prefix and suffix where prefix[i] is the minimum length of sub-array ends before i and has sum = k, suffix[i] is the minimum length of sub-array starting at or after i and has sum = k.", "The answer we are searching for is min(prefix[i] + suffix[i]) for all values of i from 0 to n-1 where n == arr.length.", "If you are still stuck with how to build prefix and suffix, you can store for each index i the length of the sub-array starts at i and has sum = k or infinity otherwise, and you can use it to build both prefix and suffix."], "metadata": {"canonical_parameter_names": ["arr", "target"], "leetcode_dataset_entry_point": "Solution().minSumOfLengths", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:20+00:00", "tests_total": 85, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "binary-search", "dynamic-programming", "sliding-window"]}, "language": "java", "interface": {"raw_signature": "public int minSumOfLengths(int[] arr, int target) {", "container": "Solution", "callable": "minSumOfLengths", "parameters": [{"name": "arr", "type": "int[]"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1478, "task_id": "allocate-mailboxes", "difficulty": "Hard", "problem_description": "Given the array houses where houses[i] is the location of the i^th house along a street and an integer k, allocate k mailboxes in the street.\n\nReturn the minimum total distance between each house and its nearest mailbox.\n\nThe test cases are generated so that the answer fits in a 32-bit integer.\n\nExample 1:\n\nInput: houses = [1,4,8,10,20], k = 3\nOutput: 5\nExplanation: Allocate mailboxes in position 3, 9 and 20.\nMinimum total distance from each houses to nearest mailboxes is |3-1| + |4-3| + |9-8| + |10-9| + |20-20| = 5\n\nExample 2:\n\nInput: houses = [2,3,5,12,18], k = 2\nOutput: 9\nExplanation: Allocate mailboxes in position 3 and 14.\nMinimum total distance from each houses to nearest mailboxes is |2-3| + |3-3| + |5-3| + |12-14| + |18-14| = 9.\n\nConstraints:\n\n- 1 <= k <= houses.length <= 100\n- 1 <= houses[i] <= 10^4\n- All the integers of houses are unique.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(houses = [10, 5, 17, 1, 18, 2, 12, 9],k = 3) == 8\n assert candidate(houses = [5, 10, 15, 20, 25],k = 2) == 15\n assert candidate(houses = [3, 6, 14, 10],k = 4) == 0\n assert candidate(houses = [3, 6, 14, 16, 25, 28, 30],k = 2) == 26\n assert candidate(houses = [1, 4, 8, 10, 20],k = 3) == 5\n assert candidate(houses = [1, 10000],k = 1) == 9999\n assert candidate(houses = [1, 2, 3, 4, 5],k = 1) == 6\n assert candidate(houses = [2, 3, 5, 12, 18],k = 2) == 9\n assert candidate(houses = [7, 4, 6, 1],k = 1) == 8\n assert candidate(houses = [5, 7, 10, 11, 12, 16],k = 3) == 4\n assert candidate(houses = [5, 10, 15, 20, 25, 30],k = 2) == 20\n assert candidate(houses = [8, 5, 2, 9, 6],k = 2) == 5\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 5\n assert candidate(houses = [10, 20, 30, 40, 50],k = 5) == 0\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 5) == 200\n assert candidate(houses = [1, 6, 9, 12, 17, 23, 30],k = 4) == 12\n assert candidate(houses = [2, 5, 7, 12, 16, 22, 26, 30, 35],k = 3) == 24\n assert candidate(houses = [1, 3, 6, 8, 12, 15, 18, 22],k = 4) == 10\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125],k = 6) == 70\n assert candidate(houses = [2, 6, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 28\n assert candidate(houses = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29],k = 4) == 18\n assert candidate(houses = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50],k = 5) == 42\n assert candidate(houses = [1, 3, 6, 8, 12, 15, 18, 22, 25, 28, 30, 33, 36, 39, 42, 45, 48],k = 6) == 32\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 100\n assert candidate(houses = [1, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 15) == 159\n assert candidate(houses = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, 861, 903, 946, 990],k = 15) == 633\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 10\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 20) == 0\n assert candidate(houses = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == 599\n assert candidate(houses = [1, 10, 100, 1000, 10000],k = 2) == 1089\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 100\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 10\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 20\n assert candidate(houses = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 3) == 225\n assert candidate(houses = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3) == 999\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 100\n assert candidate(houses = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115, 121, 127, 133, 139, 145, 151, 157, 163, 169, 175],k = 15) == 90\n assert candidate(houses = [1, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == 89\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 2) == 60\n assert candidate(houses = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90],k = 15) == 45\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 10) == 50\n assert candidate(houses = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90],k = 10) == 60\n assert candidate(houses = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145, 160, 175, 190, 200],k = 8) == 85\n assert candidate(houses = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101],k = 16) == 40\n assert candidate(houses = [1, 3, 6, 9, 12, 15, 18, 21, 24, 27],k = 3) == 23\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 10\n assert candidate(houses = [2, 8, 14, 20, 26, 32, 38, 44, 50, 56],k = 5) == 30\n assert candidate(houses = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961],k = 12) == 539\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205],k = 5) == 220\n assert candidate(houses = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 109\n assert candidate(houses = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 5) == 10\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150],k = 10) == 100\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 100\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 50\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],k = 5) == 16\n assert candidate(houses = [2, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 11) == 48\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 10) == 50\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],k = 8) == 40\n assert candidate(houses = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 3) == 36\n assert candidate(houses = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],k = 10) == 30\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225],k = 13) == 100\n assert candidate(houses = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101],k = 8) == 80\n assert candidate(houses = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],k = 5) == 199\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 50\n assert candidate(houses = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 5) == 35\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 6) == 90\n assert candidate(houses = [1, 5, 10, 20, 35, 55, 80, 110, 145, 185, 230],k = 3) == 189\n assert candidate(houses = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 7) == 139\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == 80\n assert candidate(houses = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 4) == 34\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 10\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],k = 15) == 20\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 5) == 100\n assert candidate(houses = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],k = 2) == 131\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == 80\n assert candidate(houses = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],k = 6) == 44\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 5\n assert candidate(houses = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 7) == 24\n assert candidate(houses = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],k = 6) == 154\n assert candidate(houses = [1, 3, 6, 8, 14, 15, 20, 25],k = 4) == 10\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130],k = 7) == 60\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 4) == 24\n assert candidate(houses = [1, 3, 6, 10, 15, 21, 28, 36, 45],k = 4) == 24\n assert candidate(houses = [2, 8, 15, 20, 26, 32, 40, 45, 50],k = 4) == 27\n assert candidate(houses = [7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77],k = 3) == 90\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 8\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500],k = 20) == 300\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 8) == 120\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 7) == 130\n assert candidate(houses = [1, 2, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 4) == 1697\n assert candidate(houses = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],k = 4) == 33\n assert candidate(houses = [3, 7, 11, 15, 19, 23, 27, 31],k = 3) == 20\n assert candidate(houses = [2, 5, 9, 14, 20, 27, 35, 44, 54, 65, 77, 90],k = 6) == 39\n assert candidate(houses = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100],k = 25) == 50\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 6) == 9\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 20\n assert candidate(houses = [1, 5, 9, 14, 20, 25, 30, 35, 40],k = 4) == 23\n", "comparison": "exact"}, "public_tests": ["[1,4,8,10,20]\n3", "[2,3,5,12,18]\n2"], "hints": ["If k =1, the minimum distance is obtained allocating the mailbox in the median of the array houses.", "Generalize this idea, using dynamic programming allocating k mailboxes."], "metadata": {"canonical_parameter_names": ["houses", "k"], "leetcode_dataset_entry_point": "Solution().minDistance", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:22+00:00", "tests_total": 108, "tests_dropped": 11, "flags": ["has_images"], "topic_tags": ["array", "math", "dynamic-programming", "sorting"]}, "language": "java", "interface": {"raw_signature": "public int minDistance(int[] houses, int k) {", "container": "Solution", "callable": "minDistance", "parameters": [{"name": "houses", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1480, "task_id": "running-sum-of-1d-array", "difficulty": "Easy", "problem_description": "Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]).\n\nReturn the running sum of nums.\n\nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: [1,3,6,10]\nExplanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].\n\nExample 2:\n\nInput: nums = [1,1,1,1,1]\nOutput: [1,2,3,4,5]\nExplanation: Running sum is obtained as follows: [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1].\n\nExample 3:\n\nInput: nums = [3,1,2,10,1]\nOutput: [3,4,6,16,17]\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- -10^6 <= nums[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 2, -3, 4, -5]) == [-1, 1, -2, 2, -3]\n assert candidate(nums = [-5]) == [-5]\n assert candidate(nums = [0, -1, 2, -3, 4]) == [0, -1, 1, -2, 2]\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0]\n assert candidate(nums = [1]) == [1]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000]) == [1000000, 0, 1000000, 0]\n assert candidate(nums = [1, 2, 3, 4]) == [1, 3, 6, 10]\n assert candidate(nums = [0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [0, 0, 0, 0]) == [0, 0, 0, 0]\n assert candidate(nums = [-1, -2, -3, -4]) == [-1, -3, -6, -10]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000, 1000000]) == [1000000, 0, 1000000, 0, 1000000]\n assert candidate(nums = [-1000000]) == [-1000000]\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000]) == [1000000, 2000000, 3000000, 4000000]\n assert candidate(nums = [5]) == [5]\n assert candidate(nums = [1000000]) == [1000000]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000]) == [1000000, 0, 1000000, 0]\n assert candidate(nums = [3, 1, 2, 10, 1]) == [3, 4, 6, 16, 17]\n assert candidate(nums = [1000, -500, 250, -125, 62.5, -31.25, 15.625, -7.8125, 3.90625, -1.953125, 0.9765625, -0.48828125, 0.244140625, -0.1220703125, 0.06103515625]) == [1000, 500, 750, 625, 687.5, 656.25, 671.875, 664.0625, 667.96875, 666.015625, 666.9921875, 666.50390625, 666.748046875, 666.6259765625, 666.68701171875]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [5, 15, 30, 50, 75, 105, 140, 180, 225, 275, 330, 390, 455, 525, 600, 680, 765, 855, 950, 1050]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300]) == [100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500, 5500, 6600, 7800, 9100]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 11, 111, 1111, 11111, 111111, 1111111, 1111112, 1111111, 1111112, 1111111, 1111112, 1111111, 1111112, 1111111, 1111112, 1111111]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == [-1, -3, -6, -10, -15, -21, -28, -36, -45, -55, -66, -78, -91, -105, -120, -136, -153, -171, -190, -210]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500, 5500]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [5, 20, 45, 80, 125, 180, 245, 320, 405, 500, 605]\n assert candidate(nums = [100, 50, -50, -100, 150, 200, -250, 300, -350, 400]) == [100, 150, 100, 0, 150, 350, 100, 400, 50, 450]\n assert candidate(nums = [-1000000, 500000, -250000, 125000, -62500]) == [-1000000, -500000, -750000, -625000, -687500]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == [-1, -3, -6, -10, -15, -21, -28, -36, -45, -55, -66, -78, -91, -105, -120]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000]) == [1000, 0, 2000, 0, 3000, 0, 4000, 0, 5000, 0]\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000]) == [1000000, 2000000, 3000000, 4000000]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == [10, 0, 20, 0, 30, 0, 40, 0, 50, 0]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 19, 27, 34, 40, 45, 49, 52, 54, 55]\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == [999999, 1888887, 2666664, 3333330, 3888885, 4333329, 4666662, 4888884, 4999995]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [20, 39, 57, 74, 90, 105, 119, 132, 144, 155, 165, 174, 182, 189, 195, 200, 204, 207, 209, 210]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == [10, 0, 20, 0, 30, 0]\n assert candidate(nums = [-1000, -2000, -3000, -4000, -5000, -6000, -7000, -8000, -9000, -10000]) == [-1000, -3000, -6000, -10000, -15000, -21000, -28000, -36000, -45000, -55000]\n assert candidate(nums = [500000, -500000, 500000, -500000, 500000, -500000, 500000, -500000, 500000, -500000]) == [500000, 0, 500000, 0, 500000, 0, 500000, 0, 500000, 0]\n assert candidate(nums = [5, -5, 15, -15, 25, -25]) == [5, 0, 15, 0, 25, 0]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000, 1000000]) == [1000000, 0, 1000000, 0, 1000000]\n assert candidate(nums = [1000000, -500000, 500000, -250000, 250000]) == [1000000, 500000, 1000000, 750000, 1000000]\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == [10000, 30000, 60000, 100000, 150000, 210000, 280000, 360000, 450000, 550000]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [15, 29, 42, 54, 65, 75, 84, 92, 99, 105, 110, 114, 117, 119, 120]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]\n assert candidate(nums = [-1000000, -999999, -999998, -999997, -999996, -999995]) == [-1000000, -1999999, -2999997, -3999994, -4999990, -5999985]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]\n assert candidate(nums = [999999, -999998, 999997, -999996, 999995, -999994, 999993, -999992, 999991]) == [999999, 1, 999998, 2, 999997, 3, 999996, 4, 999995]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [10, 30, 60, 100, 150, 210, 280, 360, 450, 550]\n assert candidate(nums = [0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1000000, -1000000, 500000, -500000, 250000, -250000]) == [1000000, 0, 500000, 0, 250000, 0]\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]\n assert candidate(nums = [999999, -999998, 999997, -999996, 999995, -999994, 999993, -999992]) == [999999, 1, 999998, 2, 999997, 3, 999996, 4]\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70]) == [10, -10, 20, -20, 30, -30, 40]\n assert candidate(nums = [1000000, -500000, 250000, -125000, 62500]) == [1000000, 500000, 750000, 625000, 687500]\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0]\n assert candidate(nums = [999999, 1, -999998, 2, -999997, 3]) == [999999, 1000000, 2, 4, -999993, -999990]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [-1000, 2000, -3000, 4000, -5000, 6000, -7000, 8000, -9000, 10000]) == [-1000, 1000, -2000, 2000, -3000, 3000, -4000, 4000, -5000, 5000]\n assert candidate(nums = [123456, -234567, 345678, -456789, 567890, -678901, 789012, -890123, 901234]) == [123456, -111111, 234567, -222222, 345668, -333233, 455779, -434344, 466890]\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990]) == [999999, 1999997, 2999994, 3999990, 4999985, 5999979, 6999972, 7999964, 8999955, 9999945]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == [100, 199, 297, 394, 490, 585, 679, 772, 864, 955, 1045, 1134, 1222, 1309, 1395, 1480, 1564, 1647, 1729, 1810]\n assert candidate(nums = [1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]) == [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(nums = [-999999, -888888, -777777, -666666, -555555, -444444, -333333, -222222, -111111]) == [-999999, -1888887, -2666664, -3333330, -3888885, -4333329, -4666662, -4888884, -4999995]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [500000, 250000, -125000, 62500, -31250, 15625, -7812, 3906, -1953]) == [500000, 750000, 625000, 687500, 656250, 671875, 664063, 667969, 666016]\n assert candidate(nums = [0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8]\n assert candidate(nums = [-1000000, -1000000, -1000000, -1000000]) == [-1000000, -2000000, -3000000, -4000000]\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == [1, 0, 2, 0, 3, 0]\n assert candidate(nums = [100, 200, 300, 400, 500, -1500, 600, 700, 800, 900]) == [100, 300, 600, 1000, 1500, 0, 600, 1300, 2100, 3000]\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == [5, 0, 5, 0, 5, 0, 5, 0, 5, 0]\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == [1, 2, 4, 7, 12, 20, 33, 54, 88, 143, 232, 376, 609, 986, 1596, 2583, 4180, 6764, 10945, 17710]\n assert candidate(nums = [999999, -999999, 999999, -999999, 999999, -999999, 999999, -999999, 999999, -999999]) == [999999, 0, 999999, 0, 999999, 0, 999999, 0, 999999, 0]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == [1000, 3000, 6000, 10000, 15000, 21000, 28000, 36000, 45000, 55000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140, -150]) == [-10, -30, -60, -100, -150, -210, -280, -360, -450, -550, -660, -780, -910, -1050, -1200]\n assert candidate(nums = [500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500]) == [500, 900, 1200, 1400, 1500, 1500, 1400, 1200, 900, 500, 0]\n assert candidate(nums = [100, -50, 25, -12, 6, -3, 1, 0, -1, 3, -6, 12, -24, 48, -96, 192, -384, 768, -1536, 3072]) == [100, 50, 75, 63, 69, 66, 67, 67, 66, 69, 63, 75, 51, 99, 3, 195, -189, 579, -957, 2115]\n assert candidate(nums = [1, 0, -1, 2, 0, -2, 3, 0, -3]) == [1, 1, 0, 2, 2, 0, 3, 3, 0]\n assert candidate(nums = [999999, -999998, 999997, -999996, 999995, -999994, 999993, -999992, 999991, -999990]) == [999999, 1, 999998, 2, 999997, 3, 999996, 4, 999995, 5]\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == [-10, -19, -27, -34, -40, -45, -49, -52, -54, -55]\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]", "[1,1,1,1,1]", "[3,1,2,10,1]"], "hints": ["Think about how we can calculate the i-th number in the running sum from the (i-1)-th number."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().runningSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:24+00:00", "tests_total": 95, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "prefix-sum"]}, "language": "java", "interface": {"raw_signature": "public int[] runningSum(int[] nums) {", "container": "Solution", "callable": "runningSum", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1480, "task_id": "running-sum-of-1d-array", "difficulty": "Easy", "problem_description": "Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]).\n\nReturn the running sum of nums.\n\nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: [1,3,6,10]\nExplanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].\n\nExample 2:\n\nInput: nums = [1,1,1,1,1]\nOutput: [1,2,3,4,5]\nExplanation: Running sum is obtained as follows: [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1].\n\nExample 3:\n\nInput: nums = [3,1,2,10,1]\nOutput: [3,4,6,16,17]\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- -10^6 <= nums[i] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 2, -3, 4, -5]) == [-1, 1, -2, 2, -3]\n assert candidate(nums = [-5]) == [-5]\n assert candidate(nums = [0, -1, 2, -3, 4]) == [0, -1, 1, -2, 2]\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0]\n assert candidate(nums = [1]) == [1]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000]) == [1000000, 0, 1000000, 0]\n assert candidate(nums = [1, 2, 3, 4]) == [1, 3, 6, 10]\n assert candidate(nums = [0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [0, 0, 0, 0]) == [0, 0, 0, 0]\n assert candidate(nums = [-1, -2, -3, -4]) == [-1, -3, -6, -10]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000, 1000000]) == [1000000, 0, 1000000, 0, 1000000]\n assert candidate(nums = [-1000000]) == [-1000000]\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000]) == [1000000, 2000000, 3000000, 4000000]\n assert candidate(nums = [5]) == [5]\n assert candidate(nums = [1000000]) == [1000000]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000]) == [1000000, 0, 1000000, 0]\n assert candidate(nums = [3, 1, 2, 10, 1]) == [3, 4, 6, 16, 17]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [5, 15, 30, 50, 75, 105, 140, 180, 225, 275, 330, 390, 455, 525, 600, 680, 765, 855, 950, 1050]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300]) == [100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500, 5500, 6600, 7800, 9100]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 11, 111, 1111, 11111, 111111, 1111111, 1111112, 1111111, 1111112, 1111111, 1111112, 1111111, 1111112, 1111111, 1111112, 1111111]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == [-1, -3, -6, -10, -15, -21, -28, -36, -45, -55, -66, -78, -91, -105, -120, -136, -153, -171, -190, -210]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500, 5500]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [5, 20, 45, 80, 125, 180, 245, 320, 405, 500, 605]\n assert candidate(nums = [100, 50, -50, -100, 150, 200, -250, 300, -350, 400]) == [100, 150, 100, 0, 150, 350, 100, 400, 50, 450]\n assert candidate(nums = [-1000000, 500000, -250000, 125000, -62500]) == [-1000000, -500000, -750000, -625000, -687500]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == [-1, -3, -6, -10, -15, -21, -28, -36, -45, -55, -66, -78, -91, -105, -120]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000]) == [1000, 0, 2000, 0, 3000, 0, 4000, 0, 5000, 0]\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000]) == [1000000, 2000000, 3000000, 4000000]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == [10, 0, 20, 0, 30, 0, 40, 0, 50, 0]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 19, 27, 34, 40, 45, 49, 52, 54, 55]\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == [999999, 1888887, 2666664, 3333330, 3888885, 4333329, 4666662, 4888884, 4999995]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [20, 39, 57, 74, 90, 105, 119, 132, 144, 155, 165, 174, 182, 189, 195, 200, 204, 207, 209, 210]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == [10, 0, 20, 0, 30, 0]\n assert candidate(nums = [-1000, -2000, -3000, -4000, -5000, -6000, -7000, -8000, -9000, -10000]) == [-1000, -3000, -6000, -10000, -15000, -21000, -28000, -36000, -45000, -55000]\n assert candidate(nums = [500000, -500000, 500000, -500000, 500000, -500000, 500000, -500000, 500000, -500000]) == [500000, 0, 500000, 0, 500000, 0, 500000, 0, 500000, 0]\n assert candidate(nums = [5, -5, 15, -15, 25, -25]) == [5, 0, 15, 0, 25, 0]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000, 1000000]) == [1000000, 0, 1000000, 0, 1000000]\n assert candidate(nums = [1000000, -500000, 500000, -250000, 250000]) == [1000000, 500000, 1000000, 750000, 1000000]\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == [10000, 30000, 60000, 100000, 150000, 210000, 280000, 360000, 450000, 550000]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [15, 29, 42, 54, 65, 75, 84, 92, 99, 105, 110, 114, 117, 119, 120]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]\n assert candidate(nums = [-1000000, -999999, -999998, -999997, -999996, -999995]) == [-1000000, -1999999, -2999997, -3999994, -4999990, -5999985]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]\n assert candidate(nums = [999999, -999998, 999997, -999996, 999995, -999994, 999993, -999992, 999991]) == [999999, 1, 999998, 2, 999997, 3, 999996, 4, 999995]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [10, 30, 60, 100, 150, 210, 280, 360, 450, 550]\n assert candidate(nums = [0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1000000, -1000000, 500000, -500000, 250000, -250000]) == [1000000, 0, 500000, 0, 250000, 0]\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]\n assert candidate(nums = [999999, -999998, 999997, -999996, 999995, -999994, 999993, -999992]) == [999999, 1, 999998, 2, 999997, 3, 999996, 4]\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70]) == [10, -10, 20, -20, 30, -30, 40]\n assert candidate(nums = [1000000, -500000, 250000, -125000, 62500]) == [1000000, 500000, 750000, 625000, 687500]\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0]\n assert candidate(nums = [999999, 1, -999998, 2, -999997, 3]) == [999999, 1000000, 2, 4, -999993, -999990]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [-1000, 2000, -3000, 4000, -5000, 6000, -7000, 8000, -9000, 10000]) == [-1000, 1000, -2000, 2000, -3000, 3000, -4000, 4000, -5000, 5000]\n assert candidate(nums = [123456, -234567, 345678, -456789, 567890, -678901, 789012, -890123, 901234]) == [123456, -111111, 234567, -222222, 345668, -333233, 455779, -434344, 466890]\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990]) == [999999, 1999997, 2999994, 3999990, 4999985, 5999979, 6999972, 7999964, 8999955, 9999945]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == [100, 199, 297, 394, 490, 585, 679, 772, 864, 955, 1045, 1134, 1222, 1309, 1395, 1480, 1564, 1647, 1729, 1810]\n assert candidate(nums = [1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]) == [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(nums = [-999999, -888888, -777777, -666666, -555555, -444444, -333333, -222222, -111111]) == [-999999, -1888887, -2666664, -3333330, -3888885, -4333329, -4666662, -4888884, -4999995]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [500000, 250000, -125000, 62500, -31250, 15625, -7812, 3906, -1953]) == [500000, 750000, 625000, 687500, 656250, 671875, 664063, 667969, 666016]\n assert candidate(nums = [0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8]\n assert candidate(nums = [-1000000, -1000000, -1000000, -1000000]) == [-1000000, -2000000, -3000000, -4000000]\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == [1, 0, 2, 0, 3, 0]\n assert candidate(nums = [100, 200, 300, 400, 500, -1500, 600, 700, 800, 900]) == [100, 300, 600, 1000, 1500, 0, 600, 1300, 2100, 3000]\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == [5, 0, 5, 0, 5, 0, 5, 0, 5, 0]\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == [1, 2, 4, 7, 12, 20, 33, 54, 88, 143, 232, 376, 609, 986, 1596, 2583, 4180, 6764, 10945, 17710]\n assert candidate(nums = [999999, -999999, 999999, -999999, 999999, -999999, 999999, -999999, 999999, -999999]) == [999999, 0, 999999, 0, 999999, 0, 999999, 0, 999999, 0]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == [1000, 3000, 6000, 10000, 15000, 21000, 28000, 36000, 45000, 55000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140, -150]) == [-10, -30, -60, -100, -150, -210, -280, -360, -450, -550, -660, -780, -910, -1050, -1200]\n assert candidate(nums = [500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500]) == [500, 900, 1200, 1400, 1500, 1500, 1400, 1200, 900, 500, 0]\n assert candidate(nums = [100, -50, 25, -12, 6, -3, 1, 0, -1, 3, -6, 12, -24, 48, -96, 192, -384, 768, -1536, 3072]) == [100, 50, 75, 63, 69, 66, 67, 67, 66, 69, 63, 75, 51, 99, 3, 195, -189, 579, -957, 2115]\n assert candidate(nums = [1, 0, -1, 2, 0, -2, 3, 0, -3]) == [1, 1, 0, 2, 2, 0, 3, 3, 0]\n assert candidate(nums = [999999, -999998, 999997, -999996, 999995, -999994, 999993, -999992, 999991, -999990]) == [999999, 1, 999998, 2, 999997, 3, 999996, 4, 999995, 5]\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == [-10, -19, -27, -34, -40, -45, -49, -52, -54, -55]\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4]", "[1,1,1,1,1]", "[3,1,2,10,1]"], "hints": ["Think about how we can calculate the i-th number in the running sum from the (i-1)-th number."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().runningSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:24+00:00", "tests_total": 95, "tests_dropped": 8, "flags": [], "topic_tags": ["array", "prefix-sum"]}, "language": "java", "interface": {"raw_signature": "public int[] runningSum(int[] nums) {", "container": "Solution", "callable": "runningSum", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1481, "task_id": "least-number-of-unique-integers-after-k-removals", "difficulty": "Medium", "problem_description": "Given an array of integers arr and an integer k. Find the least number of unique integers after removing exactly k elements.\n\nExample 1:\n\nInput: arr = [5,5,4], k = 1\nOutput: 1\nExplanation: Remove the single 4, only 5 is left.\n\nExample 2:\n\nInput: arr = [4,3,1,1,3,3,2], k = 3\nOutput: 2\nExplanation: Remove 4, 2 and either one of the two 1s or three 3s. 1 and 3 will be left.\n\nConstraints:\n\n- 1 <= arr.length <= 10^5\n- 1 <= arr[i] <= 10^9\n- 0 <= k <= arr.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 1, 1, 1, 1],k = 3) == 1\n assert candidate(arr = [1, 2, 3, 4, 5],k = 2) == 3\n assert candidate(arr = [10, 20, 20, 10, 10, 30, 50, 10, 20],k = 4) == 2\n assert candidate(arr = [10, 20, 30, 40, 50, 60],k = 0) == 6\n assert candidate(arr = [4, 3, 1, 1, 3, 3, 2],k = 3) == 2\n assert candidate(arr = [1, 2, 3, 4, 5],k = 0) == 5\n assert candidate(arr = [10, 10, 10, 20, 20, 30],k = 3) == 1\n assert candidate(arr = [1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(arr = [1, 2, 3, 4, 5],k = 5) == 0\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 9) == 5\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 4) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 1\n assert candidate(arr = [5, 5, 4],k = 1) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 2) == 3\n assert candidate(arr = [1, 2, 2, 3, 3, 3],k = 2) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 5) == 3\n assert candidate(arr = [10, 20, 20, 10, 10, 30, 50, 10, 20],k = 5) == 1\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50],k = 10) == 1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 30) == 2\n assert candidate(arr = [100, 100, 200, 200, 200, 300, 300, 300, 300, 400, 400, 400, 400, 400, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500],k = 15) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 15) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 20) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9],k = 18) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 50) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 5\n assert candidate(arr = [29, 30, 30, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35],k = 25) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 9],k = 20) == 3\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 30) == 4\n assert candidate(arr = [6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 10],k = 8) == 2\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 70, 70, 70, 70, 70, 70, 70, 80, 80, 80, 80, 80, 80, 80, 80, 90, 90, 90, 90, 90, 90, 90, 90, 90, 100],k = 25) == 3\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 25) == 5\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6],k = 18) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8],k = 20) == 2\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 15) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 25) == 2\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 7) == 2\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5],k = 15) == 1\n assert candidate(arr = [7, 7, 7, 7, 8, 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 13],k = 10) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 20) == 20\n assert candidate(arr = [11, 12, 12, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16],k = 8) == 3\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 5) == 2\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 30) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 14],k = 15) == 2\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60],k = 15) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 5) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 1\n assert candidate(arr = [7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12],k = 10) == 3\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 5) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 40) == 1\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 30) == 1\n assert candidate(arr = [6, 7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10],k = 10) == 1\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 20) == 4\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 30) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 10) == 3\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60],k = 12) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 25) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5],k = 15) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 15) == 2\n assert candidate(arr = [22, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28],k = 20) == 2\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 15) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 20) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 10\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 20) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 25) == 1\n assert candidate(arr = [36, 37, 37, 38, 38, 38, 39, 39, 39, 39, 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],k = 30) == 1\n assert candidate(arr = [17, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21],k = 15) == 1\n", "comparison": "exact"}, "public_tests": ["[5,5,4]\n1", "[4,3,1,1,3,3,2]\n3"], "hints": ["Use a map to count the frequencies of the numbers in the array.", "An optimal strategy is to remove the numbers with the smallest count first."], "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().findLeastNumOfUniqueInts", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:27+00:00", "tests_total": 69, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "greedy", "sorting", "counting"]}, "language": "java", "interface": {"raw_signature": "public int findLeastNumOfUniqueInts(int[] arr, int k) {", "container": "Solution", "callable": "findLeastNumOfUniqueInts", "parameters": [{"name": "arr", "type": "int[]"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1482, "task_id": "minimum-number-of-days-to-make-m-bouquets", "difficulty": "Medium", "problem_description": "You are given an integer array bloomDay, an integer m and an integer k.\n\nYou want to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden.\n\nThe garden consists of n flowers, the i^th flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet.\n\nReturn the minimum number of days you need to wait to be able to make m bouquets from the garden. If it is impossible to make m bouquets return -1.\n\nExample 1:\n\nInput: bloomDay = [1,10,3,10,2], m = 3, k = 1\nOutput: 3\nExplanation: Let us see what happened in the first three days. x means flower bloomed and _ means flower did not bloom in the garden.\nWe need 3 bouquets each should contain 1 flower.\nAfter day 1: [x, _, _, _, _] // we can only make one bouquet.\nAfter day 2: [x, _, _, _, x] // we can only make two bouquets.\nAfter day 3: [x, _, x, _, x] // we can make 3 bouquets. The answer is 3.\n\nExample 2:\n\nInput: bloomDay = [1,10,3,10,2], m = 3, k = 2\nOutput: -1\nExplanation: We need 3 bouquets each has 2 flowers, that means we need 6 flowers. We only have 5 flowers so it is impossible to get the needed bouquets and we return -1.\n\nExample 3:\n\nInput: bloomDay = [7,7,7,7,12,7,7], m = 2, k = 3\nOutput: 12\nExplanation: We need 2 bouquets each should have 3 flowers.\nHere is the garden after the 7 and 12 days:\nAfter day 7: [x, x, x, x, _, x, x]\nWe can make one bouquet of the first three flowers that bloomed. We cannot make another bouquet from the last three flowers that bloomed because they are not adjacent.\nAfter day 12: [x, x, x, x, x, x, x]\nIt is obvious that we can make two bouquets in different ways.\n\nConstraints:\n\n- bloomDay.length == n\n- 1 <= n <= 10^5\n- 1 <= bloomDay[i] <= 10^9\n- 1 <= m <= 10^6\n- 1 <= k <= n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(bloomDay = [1, 10, 3, 10, 2],m = 3,k = 1) == 3\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 5,k = 2) == 1\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5,k = 1) == 5\n assert candidate(bloomDay = [1],m = 1,k = 1) == 1\n assert candidate(bloomDay = [1000000000, 1000000000, 1000000000],m = 1,k = 3) == 1000000000\n assert candidate(bloomDay = [1, 10, 3, 10, 2],m = 3,k = 2) == -1\n assert candidate(bloomDay = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 5,k = 2) == 10\n assert candidate(bloomDay = [1000000000, 1000000000, 1000000000],m = 1,k = 2) == 1000000000\n assert candidate(bloomDay = [7, 7, 7, 7, 12, 7, 7],m = 2,k = 3) == 12\n assert candidate(bloomDay = [1, 3, 2],m = 1,k = 2) == 3\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 1,k = 10) == 10\n assert candidate(bloomDay = [1, 2, 4, 9, 3, 4, 1],m = 2,k = 2) == 4\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 2,k = 5) == 1\n assert candidate(bloomDay = [5, 8, 6, 9, 3, 2, 7, 4],m = 3,k = 2) == 8\n assert candidate(bloomDay = [5, 5, 5, 5, 5, 5],m = 2,k = 3) == 5\n assert candidate(bloomDay = [5, 8, 6, 9, 7],m = 2,k = 2) == 9\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5,k = 2) == 10\n assert candidate(bloomDay = [2, 1, 3, 1, 2],m = 3,k = 1) == 2\n assert candidate(bloomDay = [100, 100, 100, 100],m = 1,k = 4) == 100\n assert candidate(bloomDay = [1, 2, 3, 4, 5],m = 1,k = 5) == 5\n assert candidate(bloomDay = [1000000000],m = 1,k = 1) == 1000000000\n assert candidate(bloomDay = [5, 8, 6, 9, 2, 5, 9, 1, 1, 5, 1, 8, 9, 1, 8],m = 3,k = 1) == 1\n assert candidate(bloomDay = [5, 8, 6, 9, 2, 4, 7, 1, 3, 10],m = 4,k = 2) == 9\n assert candidate(bloomDay = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],m = 10,k = 2) == 20\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 2,k = 7) == 1\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 5,k = 3) == 15\n assert candidate(bloomDay = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 5,k = 3) == 6\n assert candidate(bloomDay = [30, 10, 20, 30, 20, 10, 30, 20, 10, 30],m = 3,k = 3) == 30\n assert candidate(bloomDay = [9, 1, 2, 3, 4, 5, 6, 7, 8, 1000000000],m = 1,k = 1) == 1\n assert candidate(bloomDay = [3, 5, 1, 5, 9, 6, 2, 10, 8, 7],m = 3,k = 3) == 10\n assert candidate(bloomDay = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,k = 3) == 9\n assert candidate(bloomDay = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],m = 3,k = 3) == 9\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 5,k = 5) == 1\n assert candidate(bloomDay = [2, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1],m = 8,k = 2) == 10\n assert candidate(bloomDay = [5, 3, 8, 1, 9, 2, 4, 6, 7],m = 3,k = 2) == 7\n assert candidate(bloomDay = [5, 1, 10, 2, 8, 3, 5, 10],m = 2,k = 2) == 5\n assert candidate(bloomDay = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000],m = 4,k = 2) == 1000000000\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 3,k = 5) == -1\n assert candidate(bloomDay = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 2,k = 5) == 10\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 1,k = 10) == 1\n assert candidate(bloomDay = [5, 8, 4, 3, 7, 1, 9],m = 3,k = 2) == 8\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 10,k = 1) == 1\n assert candidate(bloomDay = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 4,k = 3) == 3\n assert candidate(bloomDay = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,k = 2) == 6\n assert candidate(bloomDay = [3, 1, 5, 1, 3, 2, 5, 7, 5, 8, 4, 3],m = 3,k = 2) == 4\n assert candidate(bloomDay = [1000000000, 1000000000, 1000000000, 1000000000],m = 1,k = 4) == 1000000000\n assert candidate(bloomDay = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1],m = 4,k = 2) == 10\n assert candidate(bloomDay = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],m = 3,k = 4) == 2\n assert candidate(bloomDay = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],m = 5,k = 3) == -1\n assert candidate(bloomDay = [6, 5, 8, 10, 6, 11, 5, 3],m = 4,k = 1) == 6\n assert candidate(bloomDay = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],m = 3,k = 3) == 3\n assert candidate(bloomDay = [1, 2, 2, 1, 2, 1, 1, 2, 2, 1],m = 2,k = 3) == 2\n assert candidate(bloomDay = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 5,k = 4) == 20\n assert candidate(bloomDay = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 4,k = 2) == 8\n assert candidate(bloomDay = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10],m = 4,k = 2) == 8\n assert candidate(bloomDay = [5, 3, 3, 3, 5, 5, 2, 2, 2, 5],m = 3,k = 3) == 5\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 100,k = 5) == -1\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 3,k = 5) == 5\n assert candidate(bloomDay = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1],m = 5,k = 1) == 1\n assert candidate(bloomDay = [5, 8, 9, 6, 4, 3, 7, 2, 1],m = 4,k = 2) == 8\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 10,k = 2) == 20\n assert candidate(bloomDay = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10],m = 1,k = 10) == 10\n assert candidate(bloomDay = [2, 4, 1, 1, 1, 1, 2, 3, 3],m = 2,k = 3) == 3\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 4,k = 3) == -1\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 5,k = 3) == 1\n assert candidate(bloomDay = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],m = 1,k = 8) == 1000000000\n assert candidate(bloomDay = [5, 8, 6, 9, 10, 11, 12, 13, 14, 15],m = 4,k = 2) == 13\n assert candidate(bloomDay = [7, 7, 7, 12, 7, 7, 7, 12, 7, 7, 7, 12],m = 4,k = 3) == 12\n assert candidate(bloomDay = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 1,k = 1) == 1\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 5,k = 3) == 1\n assert candidate(bloomDay = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],m = 5,k = 3) == 2\n assert candidate(bloomDay = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],m = 5,k = 2) == 20\n assert candidate(bloomDay = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 10,k = 5) == -1\n assert candidate(bloomDay = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],m = 5,k = 4) == 10\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 15,k = 2) == 30\n assert candidate(bloomDay = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],m = 5,k = 3) == 30\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 10,k = 2) == 1\n assert candidate(bloomDay = [3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10],m = 3,k = 3) == 9\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 10,k = 1) == 10\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 3,k = 5) == 5\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 15,k = 5) == 10\n assert candidate(bloomDay = [1, 10, 3, 10, 2, 1, 10, 3, 10, 2],m = 4,k = 2) == 10\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 5,k = 3) == 15\n assert candidate(bloomDay = [9, 3, 5, 7, 2, 8, 10, 6, 4],m = 2,k = 3) == 9\n assert candidate(bloomDay = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 5,k = 4) == 7\n assert candidate(bloomDay = [5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5],m = 10,k = 2) == 3\n assert candidate(bloomDay = [5, 8, 6, 9, 7, 2, 4, 3, 10, 1],m = 2,k = 4) == 9\n assert candidate(bloomDay = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 3,k = 3) == 9\n assert candidate(bloomDay = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 5,k = 3) == 5\n assert candidate(bloomDay = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 5,k = 4) == 200\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 3,k = 3) == 9\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],m = 5,k = 5) == 25\n assert candidate(bloomDay = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],m = 10,k = 3) == 3\n", "comparison": "exact"}, "public_tests": ["[1,10,3,10,2]\n3\n1", "[1,10,3,10,2]\n3\n2", "[7,7,7,7,12,7,7]\n2\n3"], "hints": ["If we can make m or more bouquets at day x, then we can still make m or more bouquets at any day y > x.", "We can check easily if we can make enough bouquets at day x if we can get group adjacent flowers at day x."], "metadata": {"canonical_parameter_names": ["bloomDay", "m", "k"], "leetcode_dataset_entry_point": "Solution().minDays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:29+00:00", "tests_total": 93, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "binary-search"]}, "language": "java", "interface": {"raw_signature": "public int minDays(int[] bloomDay, int m, int k) {", "container": "Solution", "callable": "minDays", "parameters": [{"name": "bloomDay", "type": "int[]"}, {"name": "m", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1486, "task_id": "xor-operation-in-an-array", "difficulty": "Easy", "problem_description": "You are given an integer n and an integer start.\n\nDefine an array nums where nums[i] = start + 2 * i (0-indexed) and n == nums.length.\n\nReturn the bitwise XOR of all elements of nums.\n\nExample 1:\n\nInput: n = 5, start = 0\nOutput: 8\nExplanation: Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8.\nWhere \"^\" corresponds to bitwise XOR operator.\n\nExample 2:\n\nInput: n = 4, start = 3\nOutput: 8\nExplanation: Array nums is equal to [3, 5, 7, 9] where (3 ^ 5 ^ 7 ^ 9) = 8.\n\nConstraints:\n\n- 1 <= n <= 1000\n- 0 <= start <= 1000\n- n == nums.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,start = 3) == 8\n assert candidate(n = 8,start = 12) == 0\n assert candidate(n = 7,start = 2) == 0\n assert candidate(n = 3,start = 2) == 0\n assert candidate(n = 10,start = 1) == 2\n assert candidate(n = 5,start = 0) == 8\n assert candidate(n = 1,start = 7) == 7\n assert candidate(n = 10,start = 5) == 2\n assert candidate(n = 8,start = 2) == 16\n assert candidate(n = 7,start = 5) == 19\n assert candidate(n = 1,start = 5) == 5\n assert candidate(n = 10,start = 999) == 30\n assert candidate(n = 50,start = 25) == 2\n assert candidate(n = 100,start = 200) == 0\n assert candidate(n = 15,start = 2) == 0\n assert candidate(n = 33,start = 17) == 81\n assert candidate(n = 12,start = 8) == 0\n assert candidate(n = 750,start = 10) == 1518\n assert candidate(n = 750,start = 50) == 1598\n assert candidate(n = 3,start = 333) == 339\n assert candidate(n = 666,start = 333) == 2\n assert candidate(n = 500,start = 250) == 1048\n assert candidate(n = 12,start = 3) == 24\n assert candidate(n = 9,start = 1) == 17\n assert candidate(n = 50,start = 10) == 102\n assert candidate(n = 6,start = 999) == 22\n assert candidate(n = 8,start = 11) == 16\n assert candidate(n = 64,start = 42) == 128\n assert candidate(n = 15,start = 7) == 5\n assert candidate(n = 80,start = 600) == 0\n assert candidate(n = 250,start = 100) == 2\n assert candidate(n = 20,start = 10) == 56\n assert candidate(n = 30,start = 42) == 78\n assert candidate(n = 7,start = 25) == 39\n assert candidate(n = 256,start = 128) == 0\n assert candidate(n = 400,start = 400) == 0\n assert candidate(n = 11,start = 8) == 30\n assert candidate(n = 100,start = 250) == 312\n assert candidate(n = 20,start = 11) == 56\n assert candidate(n = 500,start = 750) == 1080\n assert candidate(n = 500,start = 500) == 0\n assert candidate(n = 700,start = 600) == 0\n assert candidate(n = 60,start = 8) == 0\n assert candidate(n = 100,start = 999) == 1864\n assert candidate(n = 250,start = 250) == 534\n assert candidate(n = 8,start = 15) == 16\n assert candidate(n = 18,start = 4) == 2\n assert candidate(n = 1000,start = 0) == 0\n assert candidate(n = 333,start = 256) == 920\n assert candidate(n = 75,start = 300) == 450\n assert candidate(n = 128,start = 99) == 256\n assert candidate(n = 500,start = 999) == 1064\n assert candidate(n = 100,start = 50) == 200\n assert candidate(n = 50,start = 50) == 166\n assert candidate(n = 250,start = 123) == 534\n assert candidate(n = 999,start = 0) == 1998\n assert candidate(n = 999,start = 500) == 2498\n assert candidate(n = 25,start = 6) == 6\n assert candidate(n = 64,start = 32) == 0\n assert candidate(n = 20,start = 12) == 0\n assert candidate(n = 50,start = 100) == 2\n assert candidate(n = 8,start = 1) == 0\n assert candidate(n = 30,start = 15) == 70\n assert candidate(n = 9,start = 7) == 7\n assert candidate(n = 13,start = 11) == 11\n assert candidate(n = 20,start = 3) == 40\n assert candidate(n = 100,start = 25) == 0\n assert candidate(n = 500,start = 0) == 0\n assert candidate(n = 120,start = 750) == 304\n assert candidate(n = 7,start = 1) == 15\n assert candidate(n = 15,start = 12) == 42\n assert candidate(n = 50,start = 0) == 2\n assert candidate(n = 1000,start = 1) == 0\n assert candidate(n = 333,start = 222) == 222\n assert candidate(n = 20,start = 15) == 56\n assert candidate(n = 7,start = 14) == 12\n assert candidate(n = 1000,start = 1000) == 0\n assert candidate(n = 800,start = 150) == 1600\n assert candidate(n = 300,start = 300) == 0\n assert candidate(n = 8,start = 100) == 0\n assert candidate(n = 7,start = 17) == 31\n assert candidate(n = 7,start = 10) == 8\n assert candidate(n = 666,start = 128) == 2\n assert candidate(n = 20,start = 2) == 40\n assert candidate(n = 300,start = 600) == 0\n assert candidate(n = 12,start = 42) == 104\n assert candidate(n = 40,start = 0) == 0\n assert candidate(n = 20,start = 0) == 0\n assert candidate(n = 80,start = 12) == 0\n assert candidate(n = 300,start = 450) == 1496\n assert candidate(n = 999,start = 1) == 1999\n assert candidate(n = 600,start = 300) == 0\n", "comparison": "exact"}, "public_tests": ["5\n0", "4\n3"], "hints": ["Simulate the process, create an array nums and return the Bitwise XOR of all elements of it."], "metadata": {"canonical_parameter_names": ["n", "start"], "leetcode_dataset_entry_point": "Solution().xorOperation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:21:33+00:00", "tests_total": 92, "tests_dropped": 0, "flags": [], "topic_tags": ["math", "bit-manipulation"]}, "language": "java", "interface": {"raw_signature": "public int xorOperation(int n, int start) {", "container": "Solution", "callable": "xorOperation", "parameters": [{"name": "n", "type": "int"}, {"name": "start", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} @@ -571,3 +571,4 @@ {"question_id": 1631, "task_id": "path-with-minimum-effort", "difficulty": "Medium", "problem_description": "You are a hiker preparing for an upcoming hike. You are given heights, a 2D array of size rows x columns, where heights[row][col] represents the height of cell (row, col). You are situated in the top-left cell, (0, 0), and you hope to travel to the bottom-right cell, (rows-1, columns-1) (i.e., 0-indexed). You can move up, down, left, or right, and you wish to find a route that requires the minimum effort.\n\nA route's effort is the maximum absolute difference in heights between two consecutive cells of the route.\n\nReturn the minimum effort required to travel from the top-left cell to the bottom-right cell.\n\nExample 1:\n\nInput: heights = [[1,2,2],[3,8,2],[5,3,5]]\nOutput: 2\nExplanation: The route of [1,3,5,3,5] has a maximum absolute difference of 2 in consecutive cells.\nThis is better than the route of [1,2,2,2,5], where the maximum absolute difference is 3.\n\nExample 2:\n\nInput: heights = [[1,2,3],[3,8,4],[5,3,5]]\nOutput: 1\nExplanation: The route of [1,2,3,4,5] has a maximum absolute difference of 1 in consecutive cells, which is better than route [1,3,5,3,5].\n\nExample 3:\n\nInput: heights = [[1,2,1,1,1],[1,2,1,2,1],[1,2,1,2,1],[1,2,1,2,1],[1,1,1,2,1]]\nOutput: 0\nExplanation: This route does not require any effort.\n\nConstraints:\n\n- rows == heights.length\n- columns == heights[i].length\n- 1 <= rows, columns <= 100\n- 1 <= heights[i][j] <= 10^6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(heights = [[4, 3, 4, 10, 5, 5, 9, 2], [10, 8, 2, 10, 9, 7, 5, 6], [5, 8, 1, 10, 10, 7, 7, 2], [5, 10, 2, 8, 3, 9, 7, 9], [7, 6, 6, 8, 6, 6, 4, 4], [4, 9, 6, 10, 2, 1, 2, 7], [5, 10, 3, 7, 7, 5, 10, 10]]) == 4\n assert candidate(heights = [[4, 3, 4, 10, 5, 5, 9, 2], [10, 8, 2, 10, 9, 7, 5, 6], [5, 8, 10, 10, 10, 7, 4, 2], [5, 1, 3, 1, 1, 3, 1, 9], [6, 4, 10, 6, 10, 9, 4, 6]]) == 5\n assert candidate(heights = [[7, 1, 4, 10, 10, 6, 9, 4, 10, 9, 7], [1, 2, 5, 9, 1, 5, 7, 5, 4, 10, 7], [6, 9, 8, 10, 9, 9, 9, 8, 10, 10, 8], [2, 7, 6, 8, 5, 5, 9, 9, 10, 10, 7], [5, 7, 6, 8, 3, 5, 6, 7, 1, 8, 6], [8, 8, 10, 10, 4, 3, 10, 7, 10, 10, 10], [9, 8, 9, 1, 2, 6, 3, 6, 8, 2, 2], [6, 9, 10, 9, 1, 6, 6, 6, 10, 8, 9], [4, 6, 10, 7, 9, 8, 3, 5, 6, 10, 2], [8, 1, 8, 5, 6, 5, 10, 8, 10, 10, 9]]) == 6\n assert candidate(heights = [[1, 10], [10, 1]]) == 9\n assert candidate(heights = [[1, 2, 1, 1, 1], [1, 2, 1, 2, 1], [1, 2, 1, 2, 1], [1, 2, 1, 2, 1], [1, 1, 1, 2, 1]]) == 0\n assert candidate(heights = [[1, 10, 6, 7, 9, 10, 4, 9]]) == 9\n assert candidate(heights = [[1, 2, 3], [3, 8, 4], [5, 3, 5]]) == 1\n assert candidate(heights = [[1, 1], [1, 1]]) == 0\n assert candidate(heights = [[1, 10, 6], [1, 3, 5], [4, 8, 2]]) == 3\n assert candidate(heights = [[1, 2, 2], [3, 8, 2], [5, 3, 5]]) == 2\n assert candidate(heights = [[1, 9, 20, 8, 15], [9, 10, 5, 11, 9], [8, 7, 2, 15, 12], [1, 11, 1, 1, 12], [20, 7, 11, 10, 2]]) == 8\n assert candidate(heights = [[4, 3, 4, 10, 5, 5, 9, 2], [10, 8, 2, 10, 9, 7, 5, 6], [5, 8, 1, 10, 10, 7, 7, 2], [10, 1, 3, 1, 1, 6, 6, 9], [6, 10, 6, 3, 9, 4, 9, 7], [1, 10, 6, 1, 2, 3, 8, 1], [6, 6, 9, 2, 3, 8, 1, 7], [10, 4, 6, 10, 4, 3, 8, 1]]) == 6\n assert candidate(heights = [[5, 8, 4, 1], [9, 6, 6, 7], [1, 6, 1, 1], [4, 9, 9, 1]]) == 5\n assert candidate(heights = [[1, 2, 1, 3, 4, 5], [1, 2, 1, 2, 2, 2], [2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1], [3, 3, 3, 3, 3, 3]]) == 2\n assert candidate(heights = [[1, 2, 3, 4, 5], [4, 3, 2, 1, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 16]]) == 5\n assert candidate(heights = [[4, 3, 4, 10, 5], [6, 7, 3, 9, 2], [3, 8, 1, 3, 4], [10, 6, 3, 2, 20], [6, 1, 1, 5, 4]]) == 3\n assert candidate(heights = [[1, 6, 5, 1, 3], [4, 7, 1, 4, 2], [6, 2, 5, 3, 1], [4, 1, 2, 1, 2], [2, 6, 3, 1, 1]]) == 3\n assert candidate(heights = [[1, 2, 100, 3, 4], [2, 3, 100, 4, 5], [3, 4, 100, 5, 6], [4, 5, 100, 6, 7], [5, 6, 100, 7, 8]]) == 94\n assert candidate(heights = [[5, 6, 2, 4, 6], [4, 8, 3, 3, 8], [8, 9, 4, 7, 10], [10, 9, 2, 3, 8], [5, 1, 5, 8, 1]]) == 7\n assert candidate(heights = [[4, 3, 2, 1], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == 4\n assert candidate(heights = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(heights = [[1, 6, 3, 1, 2], [2, 2, 5, 1, 3], [6, 1, 1, 1, 1], [2, 1, 1, 2, 1], [3, 1, 1, 1, 1]]) == 1\n assert candidate(heights = [[1, 5, 9, 8, 11, 9, 4], [3, 9, 4, 8, 15, 9, 1], [2, 9, 2, 10, 15, 1, 6], [9, 10, 2, 10, 10, 2, 3], [10, 8, 2, 10, 7, 2, 8], [6, 8, 10, 10, 8, 10, 3], [1, 7, 5, 8, 3, 7, 1]]) == 5\n assert candidate(heights = [[1, 1, 1, 1, 1, 1], [1, 100000, 1, 100000, 1, 1], [1, 1, 1, 1, 1, 1], [1, 100000, 1, 100000, 1, 1], [1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(heights = [[10, 1, 1, 1, 1], [1, 1, 1, 1, 10], [1, 1, 10, 1, 1], [1, 10, 1, 10, 1], [10, 1, 1, 1, 10]]) == 9\n assert candidate(heights = [[1, 6, 1, 1, 5], [1, 2, 9, 1, 5], [1, 3, 1, 8, 5], [1, 2, 1, 2, 5], [1, 2, 1, 2, 1]]) == 1\n assert candidate(heights = [[1000000, 999999, 999998, 999997], [999996, 999995, 999994, 999993], [999992, 999991, 999990, 999989], [999988, 999987, 999986, 999985]]) == 4\n assert candidate(heights = [[1, 3, 5, 7, 9, 11, 13], [2, 4, 6, 8, 10, 12, 14], [3, 5, 7, 9, 11, 13, 15], [4, 6, 8, 10, 12, 14, 16], [5, 7, 9, 11, 13, 15, 17]]) == 2\n assert candidate(heights = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 1\n assert candidate(heights = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 1\n assert candidate(heights = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]]) == 1\n assert candidate(heights = [[1, 10, 10, 10, 1], [10, 1, 1, 1, 1], [10, 10, 10, 1, 10], [10, 1, 1, 1, 10], [1, 1, 1, 10, 1]]) == 9\n assert candidate(heights = [[1, 100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 1]]) == 99\n assert candidate(heights = [[10, 15, 5], [20, 10, 5], [10, 10, 10]]) == 5\n assert candidate(heights = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 5, 4, 3, 1], [1, 2, 3, 4, 5, 6, 5, 4, 3, 1], [1, 2, 3, 4, 5, 5, 5, 4, 3, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1]]) == 0\n assert candidate(heights = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [8, 7, 6, 5, 4, 3, 2, 1, 9], [7, 6, 5, 4, 3, 2, 1, 9, 8], [6, 5, 4, 3, 2, 1, 9, 8, 7], [5, 4, 3, 2, 1, 9, 8, 7, 6], [4, 3, 2, 1, 9, 8, 7, 6, 5], [3, 2, 1, 9, 8, 7, 6, 5, 4], [2, 1, 9, 8, 7, 6, 5, 4, 3], [1, 9, 8, 7, 6, 5, 4, 3, 2]]) == 8\n assert candidate(heights = [[1, 100, 1], [1, 100, 1], [1, 100, 1], [1, 100, 1], [1, 1, 1]]) == 0\n assert candidate(heights = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]]) == 1\n assert candidate(heights = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41]]) == 10\n assert candidate(heights = [[1, 6, 7, 5, 3, 1, 2, 6, 3, 10], [10, 1, 5, 8, 2, 10, 4, 10, 8, 7], [1, 9, 3, 5, 7, 4, 5, 10, 9, 8], [10, 8, 7, 5, 1, 10, 1, 10, 3, 7], [1, 10, 8, 1, 3, 8, 10, 7, 1, 10], [1, 5, 4, 4, 3, 2, 8, 3, 9, 9], [9, 6, 7, 4, 3, 2, 1, 8, 7, 6], [5, 2, 1, 3, 2, 3, 4, 5, 6, 7], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 9\n assert candidate(heights = [[1, 6, 3, 8, 5, 4, 2, 7, 9], [6, 3, 8, 5, 4, 2, 7, 9, 1], [3, 8, 5, 4, 2, 7, 9, 1, 6], [8, 5, 4, 2, 7, 9, 1, 6, 3], [5, 4, 2, 7, 9, 1, 6, 3, 8], [4, 2, 7, 9, 1, 6, 3, 8, 5], [2, 7, 9, 1, 6, 3, 8, 5, 4], [7, 9, 1, 6, 3, 8, 5, 4, 2], [9, 1, 6, 3, 8, 5, 4, 2, 7]]) == 8\n assert candidate(heights = [[5, 6, 7, 8, 9], [4, 3, 2, 1, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 5\n assert candidate(heights = [[1, 2, 3], [6, 5, 4], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]]) == 3\n assert candidate(heights = [[4, 3, 4, 10, 5, 5, 9, 2], [10, 8, 2, 10, 9, 7, 5, 6], [5, 5, 1, 3, 1, 3, 7, 6], [8, 1, 2, 1, 6, 8, 5, 1], [2, 1, 1, 8, 1, 5, 6, 1], [1, 1, 8, 1, 5, 9, 1, 4], [3, 1, 2, 5, 4, 8, 3, 1]]) == 4\n assert candidate(heights = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 5\n assert candidate(heights = [[8, 5, 2], [6, 7, 3], [5, 1, 4], [6, 9, 8], [9, 3, 7]]) == 3\n assert candidate(heights = [[7, 9, 6, 9, 6], [6, 6, 8, 6, 6], [6, 9, 7, 9, 6], [9, 6, 9, 9, 6], [6, 9, 8, 9, 6], [6, 6, 9, 6, 6]]) == 2\n assert candidate(heights = [[5, 3, 1], [6, 4, 2], [7, 5, 3], [8, 6, 4], [9, 7, 5], [10, 8, 6]]) == 2\n assert candidate(heights = [[20, 21, 22, 23, 24, 25], [19, 18, 17, 16, 15, 14], [13, 12, 11, 10, 9, 8], [7, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 6]]) == 6\n assert candidate(heights = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(heights = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [21, 22, 23, 24, 25]]) == 1\n assert candidate(heights = [[1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]]) == 1\n assert candidate(heights = [[1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(heights = [[10, 8, 9, 10, 12], [13, 14, 15, 16, 17], [18, 19, 20, 21, 22], [23, 24, 25, 26, 27], [28, 29, 30, 31, 32]]) == 5\n assert candidate(heights = [[5, 8, 1, 3, 5, 6], [3, 5, 4, 5, 6, 6], [1, 3, 5, 8, 2, 2], [6, 6, 3, 3, 2, 6], [8, 5, 1, 1, 2, 5], [9, 5, 3, 3, 4, 1]]) == 3\n assert candidate(heights = [[10, 18, 16, 19], [6, 13, 8, 15], [7, 19, 18, 17], [4, 9, 9, 18], [3, 5, 12, 9]]) == 4\n assert candidate(heights = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9]]) == 2\n assert candidate(heights = [[1, 3, 1, 3, 1, 3], [2, 1, 2, 1, 2, 1], [3, 2, 3, 2, 3, 2], [1, 3, 1, 3, 1, 3], [2, 1, 2, 1, 2, 1]]) == 2\n assert candidate(heights = [[7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 1, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 1, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 1, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 1, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 1]]) == 6\n assert candidate(heights = [[10, 11, 12, 13, 14], [9, 8, 7, 6, 5], [4, 3, 2, 1, 100], [101, 102, 103, 104, 105], [106, 107, 108, 109, 110]]) == 95\n assert candidate(heights = [[5, 3, 1, 1, 1], [4, 2, 1, 1, 1], [4, 2, 1, 1, 1], [4, 2, 1, 1, 1], [4, 3, 2, 2, 1]]) == 1\n assert candidate(heights = [[1, 2, 2, 1, 2, 1, 2, 1], [2, 1, 1, 2, 1, 2, 1, 2], [1, 2, 2, 1, 2, 1, 2, 1], [2, 1, 1, 2, 1, 2, 1, 2], [1, 2, 2, 1, 2, 1, 2, 1]]) == 1\n assert candidate(heights = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24], [25, 26, 27], [28, 29, 30]]) == 3\n assert candidate(heights = [[1, 2, 3, 4, 5], [6, 5, 4, 3, 2], [3, 4, 5, 6, 7], [8, 7, 6, 5, 4], [9, 10, 11, 12, 13]]) == 1\n assert candidate(heights = [[1, 5, 5, 1], [5, 1, 5, 5], [1, 5, 1, 5], [5, 1, 5, 1]]) == 4\n assert candidate(heights = [[1, 6, 3, 7, 2, 8], [4, 5, 2, 6, 8, 5], [3, 9, 4, 10, 12, 1], [9, 3, 8, 11, 14, 6], [12, 11, 9, 13, 15, 7]]) == 5\n assert candidate(heights = [[1, 9, 3, 1, 2], [9, 9, 9, 1, 1], [1, 9, 9, 9, 1], [1, 1, 1, 1, 1], [2, 1, 1, 1, 3]]) == 8\n assert candidate(heights = [[5, 5, 5, 5, 5], [5, 4, 4, 4, 5], [5, 4, 3, 4, 5], [5, 4, 4, 4, 5], [5, 5, 5, 5, 5]]) == 0\n", "comparison": "exact"}, "public_tests": ["[[1,2,2],[3,8,2],[5,3,5]]", "[[1,2,3],[3,8,4],[5,3,5]]", "[[1,2,1,1,1],[1,2,1,2,1],[1,2,1,2,1],[1,2,1,2,1],[1,1,1,2,1]]"], "hints": ["Consider the grid as a graph, where adjacent cells have an edge with cost of the difference between the cells.", "If you are given threshold k, check if it is possible to go from (0, 0) to (n-1, m-1) using only edges of ≤ k cost.", "Binary search the k value."], "metadata": {"canonical_parameter_names": ["heights"], "leetcode_dataset_entry_point": "Solution().minimumEffortPath", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:53+00:00", "tests_total": 69, "tests_dropped": 1, "flags": ["has_images"], "topic_tags": ["array", "binary-search", "depth-first-search", "breadth-first-search", "union-find", "heap-priority-queue", "matrix", "dijkstra"]}, "language": "java", "interface": {"raw_signature": "public int minimumEffortPath(int[][] heights) {", "container": "Solution", "callable": "minimumEffortPath", "parameters": [{"name": "heights", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1632, "task_id": "rank-transform-of-a-matrix", "difficulty": "Hard", "problem_description": "Given an m x n matrix, return a new matrix answer where answer[row][col] is the rank of matrix[row][col].\n\nThe rank is an integer that represents how large an element is compared to other elements. It is calculated using the following rules:\n\n- The rank is an integer starting from 1.\n- If two elements p and q are in the same row or column, then:\n - If p < q then rank(p) < rank(q)\n - If p == q then rank(p) == rank(q)\n - If p > q then rank(p) > rank(q)\n- The rank should be as small as possible.\n\nThe test cases are generated so that answer is unique under the given rules.\n\nExample 1:\n\nInput: matrix = [[1,2],[3,4]]\nOutput: [[1,2],[2,3]]\nExplanation:\nThe rank of matrix[0][0] is 1 because it is the smallest integer in its row and column.\nThe rank of matrix[0][1] is 2 because matrix[0][1] > matrix[0][0] and matrix[0][0] is rank 1.\nThe rank of matrix[1][0] is 2 because matrix[1][0] > matrix[0][0] and matrix[0][0] is rank 1.\nThe rank of matrix[1][1] is 3 because matrix[1][1] > matrix[0][1], matrix[1][1] > matrix[1][0], and both matrix[0][1] and matrix[1][0] are rank 2.\n\nExample 2:\n\nInput: matrix = [[7,7],[7,7]]\nOutput: [[1,1],[1,1]]\n\nExample 3:\n\nInput: matrix = [[20,-21,14],[-19,4,19],[22,-47,24],[-19,4,19]]\nOutput: [[4,2,3],[1,3,4],[5,1,6],[1,3,4]]\n\nConstraints:\n\n- m == matrix.length\n- n == matrix[i].length\n- 1 <= m, n <= 500\n- -10^9 <= matrix[row][col] <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[-1, -2], [-3, -4]]) == [[3, 2], [2, 1]]\n assert candidate(matrix = [[20, -21, 14], [-19, 4, 19], [22, -47, 24], [-19, 4, 19]]) == [[4, 2, 3], [1, 3, 4], [5, 1, 6], [1, 3, 4]]\n assert candidate(matrix = [[1, 2], [3, 4]]) == [[1, 2], [2, 3]]\n assert candidate(matrix = [[-3, -3], [1, -2], [2, -2], [1, 2]]) == [[1, 1], [3, 2], [4, 2], [3, 4]]\n assert candidate(matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(matrix = [[7, 7], [7, 7]]) == [[1, 1], [1, 1]]\n assert candidate(matrix = [[1, 2, 3], [3, 2, 1], [2, 1, 3]]) == [[1, 2, 3], [3, 2, 1], [2, 1, 3]]\n assert candidate(matrix = [[3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(matrix = [[-1, -1, -1], [-1, 0, -1], [-1, -1, -1]]) == [[1, 1, 1], [1, 2, 1], [1, 1, 1]]\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == [[5, 4, 3], [4, 3, 2], [3, 2, 1]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2], [3, 4, 5, 6, 1, 2], [2, 1, 6, 5, 4, 3]]) == [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2], [3, 4, 5, 6, 1, 2], [2, 1, 6, 5, 4, 3]]\n assert candidate(matrix = [[10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 20, 30]]) == [[1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3]]\n assert candidate(matrix = [[1, 0, -1], [0, 0, 0], [-1, 0, 1]]) == [[3, 2, 1], [2, 2, 2], [1, 2, 3]]\n assert candidate(matrix = [[-5, -4, -3, -2, -1], [0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]\n assert candidate(matrix = [[10, 9, 8, 7, 6], [9, 8, 7, 6, 5], [8, 7, 6, 5, 4], [7, 6, 5, 4, 3], [6, 5, 4, 3, 2], [5, 4, 3, 2, 1], [4, 3, 2, 1, 0], [3, 2, 1, 0, -1], [2, 1, 0, -1, -2], [1, 0, -1, -2, -3]]) == [[14, 13, 12, 11, 10], [13, 12, 11, 10, 9], [12, 11, 10, 9, 8], [11, 10, 9, 8, 7], [10, 9, 8, 7, 6], [9, 8, 7, 6, 5], [8, 7, 6, 5, 4], [7, 6, 5, 4, 3], [6, 5, 4, 3, 2], [5, 4, 3, 2, 1]]\n assert candidate(matrix = [[-10, -10, -10], [-10, -10, -10], [-10, -10, -10]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(matrix = [[-1, 0, 1], [0, 0, 0], [1, 0, -1], [0, 1, 0]]) == [[1, 2, 3], [2, 2, 2], [3, 2, 1], [2, 3, 2]]\n assert candidate(matrix = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]\n assert candidate(matrix = [[10, 20, 30, 40, 50], [40, 50, 10, 20, 30], [30, 40, 50, 10, 20], [20, 30, 40, 50, 10], [50, 10, 20, 30, 40]]) == [[1, 2, 3, 4, 5], [4, 5, 1, 2, 3], [3, 4, 5, 1, 2], [2, 3, 4, 5, 1], [5, 1, 2, 3, 4]]\n assert candidate(matrix = [[9, 9, 9, 9, 9, 9, 9, 9, 9, 9], [8, 8, 8, 8, 8, 8, 8, 8, 8, 8], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9], [8, 8, 8, 8, 8, 8, 8, 8, 8, 8], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(matrix = [[100, 90, 80], [70, 60, 50], [40, 30, 20], [10, 0, -10]]) == [[6, 5, 4], [5, 4, 3], [4, 3, 2], [3, 2, 1]]\n assert candidate(matrix = [[10, 10, 10, 10], [10, 20, 20, 10], [10, 20, 30, 10], [10, 10, 10, 10]]) == [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 3, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0, 2, 4, 6, 8], [0, 3, 6, 9, 12], [0, 4, 8, 12, 16]]) == [[1, 1, 1, 1, 1], [1, 2, 3, 4, 5], [1, 3, 4, 5, 6], [1, 4, 5, 6, 7], [1, 5, 6, 7, 8]]\n assert candidate(matrix = [[7, -3, 10], [3, 7, 1], [-3, 10, 7], [10, 1, 3]]) == [[3, 1, 5], [2, 3, 1], [1, 5, 4], [4, 2, 3]]\n assert candidate(matrix = [[-10, -9, -8, -7, -6], [-9, -8, -7, -6, -5], [-8, -7, -6, -5, -4], [-7, -6, -5, -4, -3], [-6, -5, -4, -3, -2], [-5, -4, -3, -2, -1], [-4, -3, -2, -1, 0], [-3, -2, -1, 0, 1], [-2, -1, 0, 1, 2], [-1, 0, 1, 2, 3]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9], [6, 7, 8, 9, 10], [7, 8, 9, 10, 11], [8, 9, 10, 11, 12], [9, 10, 11, 12, 13], [10, 11, 12, 13, 14]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]\n assert candidate(matrix = [[-10, 5, 3, -5], [0, 0, 0, 0], [-10, 5, 3, -5], [10, -5, -3, 5]]) == [[1, 5, 4, 2], [3, 3, 3, 3], [1, 5, 4, 2], [5, 1, 2, 4]]\n assert candidate(matrix = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]) == [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]\n assert candidate(matrix = [[0, 1, 2, 3, 4], [4, 3, 2, 1, 0], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [0, 2, 4, 6, 8]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 4, 5, 6, 7], [7, 6, 5, 4, 2], [1, 3, 4, 5, 6]]\n assert candidate(matrix = [[-10, 9, 6, 1, 6, 8, 3, -1, 5, 3, 0], [9, -10, -8, -10, 2, 3, 8, 10, 4, 5, -8], [6, -8, 10, -8, 10, 3, -8, 5, -9, 3, -10], [1, 10, -10, 3, -8, 8, 5, 10, -1, 2, -8], [6, -8, 10, -8, 10, 3, -8, 5, -9, 3, -10], [8, 3, -10, 8, 5, 10, -1, 2, -8, 1, 6], [-1, 5, -9, -1, 2, -8, 1, 6, 8, 3, 0], [5, 3, 8, -1, 6, 10, 3, -8, 1, 6, -8], [3, 0, 3, 5, -1, 6, 8, 3, 0, 3, 10], [3, -10, 3, -8, 10, -8, 5, 10, -1, 2, 6], [0, 3, 10, -8, 3, -10, 8, 5, -1, 2, 6]]) == [[1, 13, 11, 6, 11, 12, 8, 4, 10, 8, 5], [12, 1, 3, 1, 7, 8, 11, 14, 9, 10, 3], [10, 3, 14, 3, 14, 8, 3, 9, 2, 8, 1], [6, 14, 1, 8, 3, 12, 9, 14, 4, 7, 3], [10, 3, 14, 3, 14, 8, 3, 9, 2, 8, 1], [11, 8, 1, 11, 9, 13, 4, 6, 3, 5, 10], [4, 9, 2, 4, 7, 3, 6, 10, 11, 8, 5], [9, 8, 12, 4, 11, 13, 8, 3, 6, 11, 3], [8, 5, 8, 9, 4, 10, 11, 8, 5, 8, 12], [8, 1, 8, 3, 14, 3, 9, 14, 4, 7, 10], [5, 8, 14, 3, 8, 1, 11, 9, 4, 7, 10]]\n assert candidate(matrix = [[1, 2, 3], [3, 2, 1], [2, 1, 3]]) == [[1, 2, 3], [3, 2, 1], [2, 1, 3]]\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]\n assert candidate(matrix = [[1, 3, 1, 3, 1], [2, 4, 2, 4, 2], [1, 3, 1, 3, 1], [2, 4, 2, 4, 2]]) == [[1, 2, 1, 2, 1], [2, 3, 2, 3, 2], [1, 2, 1, 2, 1], [2, 3, 2, 3, 2]]\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]]) == [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [4, 5, 6, 7, 8], [7, 8, 9, 10, 11], [10, 11, 12, 13, 14], [13, 14, 15, 16, 17]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]\n assert candidate(matrix = [[10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10]]) == [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[-10, 5, 0, 3], [6, -10, 8, 2], [1, 10, -5, 7], [4, -3, 9, -10]]) == [[1, 4, 2, 3], [4, 1, 5, 2], [2, 5, 1, 4], [3, 2, 6, 1]]\n assert candidate(matrix = [[-1, -1, -1, -1], [-1, 0, 0, -1], [-1, 0, 1, -1], [-1, -1, -1, 1]]) == [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 3, 1], [1, 1, 1, 2]]\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(matrix = [[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12], [5, 9, 13]]) == [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]\n assert candidate(matrix = [[1, 1000000000, -1000000000], [1000000000, 1, -1000000000], [-1000000000, -1000000000, 1]]) == [[2, 3, 1], [3, 2, 1], [1, 1, 2]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 1], [3, 4, 5, 1, 2], [4, 5, 1, 2, 3], [5, 1, 2, 3, 4]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 1], [3, 4, 5, 1, 2], [4, 5, 1, 2, 3], [5, 1, 2, 3, 4]]\n assert candidate(matrix = [[-10, 0, 10], [0, 0, 0], [-10, 0, 10]]) == [[1, 2, 3], [2, 2, 2], [1, 2, 3]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 2, 4], [4, 2, 1, 5, 3], [2, 4, 6, 8, 10]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 2, 4], [4, 2, 1, 5, 3], [2, 4, 6, 7, 8]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]\n assert candidate(matrix = [[0, -1, 1000000000, 0], [1000000000, 0, -1, 0], [-1, 1000000000, 0, 0], [0, 0, 0, 0]]) == [[2, 1, 3, 2], [3, 2, 1, 2], [1, 3, 2, 2], [2, 2, 2, 2]]\n assert candidate(matrix = [[5, 1, 3, 2, 1], [5, 5, 4, 4, 5], [4, 2, 3, 3, 2], [5, 5, 5, 5, 5], [4, 4, 4, 4, 4]]) == [[5, 1, 3, 2, 1], [5, 5, 4, 4, 5], [4, 2, 3, 3, 2], [5, 5, 5, 5, 5], [4, 4, 4, 4, 4]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1], [1, 2, 3, 4, 5, 6]]) == [[1, 2, 3, 4, 5, 6], [5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1], [1, 2, 3, 4, 5, 6]]\n assert candidate(matrix = [[-1, -1, -1, -1, -1], [-1, 1, -1, 1, -1], [-1, -1, -1, -1, -1], [-1, 1, -1, 1, -1], [-1, -1, -1, -1, -1]]) == [[1, 1, 1, 1, 1], [1, 2, 1, 2, 1], [1, 1, 1, 1, 1], [1, 2, 1, 2, 1], [1, 1, 1, 1, 1]]\n assert candidate(matrix = [[0, 1, 2, 3, 4], [4, 3, 2, 1, 0], [1, 3, 0, 2, 4], [2, 4, 1, 0, 3], [3, 0, 4, 1, 2]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 4, 1, 3, 5], [3, 5, 2, 1, 4], [4, 1, 5, 2, 3]]\n assert candidate(matrix = [[-1000000000, 1000000000], [1000000000, -1000000000]]) == [[1, 2], [2, 1]]\n assert candidate(matrix = [[1, 2, 3, 4], [2, 1, 4, 3], [3, 4, 1, 2], [4, 3, 2, 1]]) == [[1, 2, 3, 4], [2, 1, 4, 3], [3, 4, 1, 2], [4, 3, 2, 1]]\n assert candidate(matrix = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == [[1, 1, 1], [1, 2, 1], [1, 1, 1]]\n assert candidate(matrix = [[5, 3, 1], [-1, 7, 6], [8, 4, 2]]) == [[3, 2, 1], [1, 4, 3], [4, 3, 2]]\n assert candidate(matrix = [[5, 1, 9, 11], [2, 4, 6, 8], [13, 3, 7, 15], [16, 14, 12, 10]]) == [[2, 1, 6, 7], [1, 3, 4, 5], [6, 2, 5, 8], [9, 8, 7, 6]]\n assert candidate(matrix = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]) == [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[1, 1, 1], [1, 2, 2], [1, 2, 3]]) == [[1, 1, 1], [1, 2, 2], [1, 2, 3]]\n assert candidate(matrix = [[-10, -10, -10, -10], [-10, 0, 0, -10], [-10, 0, 0, -10], [-10, -10, -10, -10]]) == [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 2, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]) == [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]\n assert candidate(matrix = [[5, -4, 5, -9, -1], [9, -1, 9, 5, -5], [5, -5, 5, 9, 9], [9, 9, 9, 5, -1], [5, -4, 5, -9, -1]]) == [[4, 2, 4, 1, 3], [5, 3, 5, 4, 1], [4, 1, 4, 5, 5], [5, 5, 5, 4, 3], [4, 2, 4, 1, 3]]\n assert candidate(matrix = [[-10, 20, 30, -40], [-10, 20, 30, -40], [-10, 20, 30, -40], [-10, 20, 30, -40]]) == [[2, 3, 4, 1], [2, 3, 4, 1], [2, 3, 4, 1], [2, 3, 4, 1]]\n assert candidate(matrix = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 3, 4, 1], [3, 4, 1, 2]]) == [[1, 2, 3, 4], [4, 3, 2, 1], [2, 3, 4, 1], [3, 4, 1, 2]]\n assert candidate(matrix = [[5, 1, 9, 11], [2, 4, 8, 10], [13, 3, 6, 7], [15, 14, 12, 16]]) == [[2, 1, 5, 6], [1, 3, 4, 5], [5, 2, 3, 4], [8, 7, 6, 9]]\n assert candidate(matrix = [[-1, -2, -3], [-2, -3, -4], [-3, -4, -5]]) == [[5, 4, 3], [4, 3, 2], [3, 2, 1]]\n assert candidate(matrix = [[10, 20, 30, 40], [40, 30, 20, 10], [10, 20, 30, 40], [40, 30, 20, 10]]) == [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1]]\n assert candidate(matrix = [[-1, -2, -3, -4, -5], [-6, -7, -8, -9, -10], [-11, -12, -13, -14, -15], [-16, -17, -18, -19, -20], [-21, -22, -23, -24, -25]]) == [[9, 8, 7, 6, 5], [8, 7, 6, 5, 4], [7, 6, 5, 4, 3], [6, 5, 4, 3, 2], [5, 4, 3, 2, 1]]\n assert candidate(matrix = [[-10, 100, 0], [5, -5, 5], [10, 10, 10], [0, 0, 0]]) == [[1, 5, 2], [3, 1, 3], [4, 4, 4], [2, 2, 2]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [2, 1, 4, 3, 5], [3, 4, 1, 2, 5], [4, 3, 2, 1, 5], [5, 5, 5, 5, 5]]) == [[1, 2, 3, 4, 5], [2, 1, 4, 3, 5], [3, 4, 1, 2, 5], [4, 3, 2, 1, 5], [5, 5, 5, 5, 5]]\n assert candidate(matrix = [[100, 200, 300, 400, 500], [500, 400, 300, 200, 100], [200, 300, 400, 500, 100], [400, 500, 100, 200, 300], [300, 100, 200, 300, 400]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1], [4, 5, 1, 2, 3], [3, 1, 2, 3, 4]]\n assert candidate(matrix = [[-10, 0, 10], [20, 30, 40], [50, 60, 70]]) == [[1, 2, 3], [2, 3, 4], [3, 4, 5]]\n assert candidate(matrix = [[-5, -5, -5], [-5, -5, -5], [-5, -5, -5], [-5, -5, -5]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2]]) == [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2]]\n assert candidate(matrix = [[-10, -20, -30], [-5, -15, -25], [-1, -11, -21]]) == [[3, 2, 1], [4, 3, 2], [5, 4, 3]]\n assert candidate(matrix = [[1], [2], [3], [4], [5]]) == [[1], [2], [3], [4], [5]]\n assert candidate(matrix = [[1, 1, 2], [2, 2, 1], [3, 3, 2]]) == [[1, 1, 2], [2, 2, 1], [3, 3, 2]]\n assert candidate(matrix = [[1, 3, 5], [2, 3, 6], [4, 6, 9]]) == [[1, 3, 4], [2, 3, 5], [3, 4, 6]]\n assert candidate(matrix = [[5, 3, 1, 4, 2], [10, 8, 6, 9, 7], [15, 13, 11, 14, 12], [20, 18, 16, 19, 17], [25, 23, 21, 24, 22]]) == [[5, 3, 1, 4, 2], [6, 4, 2, 5, 3], [7, 5, 3, 6, 4], [8, 6, 4, 7, 5], [9, 7, 5, 8, 6]]\n assert candidate(matrix = [[5, 1, 9, 5, 5], [1, 5, 5, 9, 1], [9, 5, 1, 1, 5], [5, 9, 5, 5, 1], [5, 5, 1, 5, 9]]) == [[2, 1, 3, 2, 2], [1, 2, 2, 3, 1], [3, 2, 1, 1, 2], [2, 3, 2, 2, 1], [2, 2, 1, 2, 3]]\n assert candidate(matrix = [[1000000000, 999999999, 999999998, 999999997], [999999996, 999999995, 999999994, 999999993], [999999992, 999999991, 999999990, 999999989], [999999988, 999999987, 999999986, 999999985]]) == [[7, 6, 5, 4], [6, 5, 4, 3], [5, 4, 3, 2], [4, 3, 2, 1]]\n assert candidate(matrix = [[-5, -4, -3, -2, -1], [-4, -3, -2, -1, 0], [-3, -2, -1, 0, 1], [-2, -1, 0, 1, 2], [-1, 0, 1, 2, 3]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]\n assert candidate(matrix = [[5, 1, 9, 1, 5, 9], [1, 5, 5, 1, 5, 1], [9, 5, 1, 9, 1, 9]]) == [[2, 1, 3, 1, 2, 3], [1, 2, 2, 1, 2, 1], [3, 2, 1, 3, 1, 3]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1], [3, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3], [5, 6, 1, 2, 3, 4], [6, 1, 2, 3, 4, 5]]) == [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1], [3, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3], [5, 6, 1, 2, 3, 4], [6, 1, 2, 3, 4, 5]]\n assert candidate(matrix = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]\n assert candidate(matrix = [[-1, -10, 100, 50, 25], [-1, -20, 99, 49, 24], [0, 0, 0, 0, 0], [1, 2, 3, 4, 5], [10, 20, 30, 40, 50]]) == [[3, 2, 13, 12, 11], [3, 1, 12, 11, 10], [4, 4, 4, 4, 4], [5, 6, 7, 8, 9], [6, 7, 8, 9, 12]]\n assert candidate(matrix = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]\n assert candidate(matrix = [[9, 7, 5], [6, 8, 4], [3, 1, 2]]) == [[6, 5, 4], [4, 6, 3], [3, 1, 2]]\n assert candidate(matrix = [[-1, 0, 0, 1, 2], [-1, -1, 1, 1, 2], [1, 1, 1, 1, 1], [-1, 0, 0, 1, 1], [-1, -1, 1, 1, 1]]) == [[1, 2, 2, 3, 4], [1, 1, 3, 3, 4], [3, 3, 3, 3, 3], [1, 2, 2, 3, 3], [1, 1, 3, 3, 3]]\n assert candidate(matrix = [[0, 0, 0, 0], [0, 1, 1, 1], [0, 1, 2, 2], [0, 1, 2, 3]]) == [[1, 1, 1, 1], [1, 2, 2, 2], [1, 2, 3, 3], [1, 2, 3, 4]]\n assert candidate(matrix = [[10, 20, 30], [20, 30, 10], [30, 10, 20]]) == [[1, 2, 3], [2, 3, 1], [3, 1, 2]]\n assert candidate(matrix = [[5, 1, 3, 1], [2, 4, 6, 4], [7, 8, 9, 8], [1, 3, 5, 3]]) == [[3, 1, 2, 1], [2, 3, 4, 3], [4, 5, 6, 5], [1, 2, 3, 2]]\n assert candidate(matrix = [[-1, -2, -3], [-3, -1, -2], [-2, -3, -1]]) == [[3, 2, 1], [1, 3, 2], [2, 1, 3]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1], [4, 5, 1, 2, 3], [3, 1, 2, 4, 5]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1], [4, 5, 1, 2, 3], [3, 1, 2, 4, 5]]\n assert candidate(matrix = [[1000000000, -1000000000, 1000000000, -1000000000], [-1000000000, 1000000000, -1000000000, 1000000000], [1000000000, -1000000000, 1000000000, -1000000000], [-1000000000, 1000000000, -1000000000, 1000000000]]) == [[2, 1, 2, 1], [1, 2, 1, 2], [2, 1, 2, 1], [1, 2, 1, 2]]\n assert candidate(matrix = [[-5, -5, -5, -5], [-5, -5, -5, -5], [-5, -5, -5, -5], [-5, -5, -5, -5]]) == [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 1], [1, 10, 9, 8, 7, 6, 5, 4, 3, 2], [3, 2, 1, 10, 9, 8, 7, 6, 5, 4], [4, 5, 6, 7, 8, 9, 10, 1, 2, 3], [5, 6, 7, 8, 9, 10, 1, 2, 3, 4], [6, 7, 8, 9, 10, 1, 2, 3, 4, 5], [7, 8, 9, 10, 1, 2, 3, 4, 5, 6], [8, 9, 10, 1, 2, 3, 4, 5, 6, 7]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 1], [1, 10, 9, 8, 7, 6, 5, 4, 3, 2], [3, 2, 1, 10, 9, 8, 7, 6, 5, 4], [4, 5, 6, 7, 8, 9, 10, 1, 2, 3], [5, 6, 7, 8, 9, 10, 1, 2, 3, 4], [6, 7, 8, 9, 10, 1, 2, 3, 4, 5], [7, 8, 9, 10, 1, 2, 3, 4, 5, 6], [8, 9, 10, 1, 2, 3, 4, 5, 6, 7]]\n assert candidate(matrix = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1]]) == [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1]]\n", "comparison": "exact"}, "public_tests": ["[[1,2],[3,4]]", "[[7,7],[7,7]]", "[[20,-21,14],[-19,4,19],[22,-47,24],[-19,4,19]]"], "hints": ["Sort the cells by value and process them in increasing order.", "The rank of a cell is the maximum rank in its row and column plus one.", "Handle the equal cells by treating them as components using a union-find data structure."], "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().matrixRankTransform", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:56+00:00", "tests_total": 96, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "union-find", "graph", "topological-sort", "sorting", "matrix"]}, "language": "java", "interface": {"raw_signature": "public int[][] matrixRankTransform(int[][] matrix) {", "container": "Solution", "callable": "matrixRankTransform", "parameters": [{"name": "matrix", "type": "int[][]"}], "return_type": "int[][]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1636, "task_id": "sort-array-by-increasing-frequency", "difficulty": "Easy", "problem_description": "Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same frequency, sort them in decreasing order.\n\nReturn the sorted array.\n\nExample 1:\n\nInput: nums = [1,1,2,2,2,3]\nOutput: [3,1,1,2,2,2]\nExplanation: '3' has a frequency of 1, '1' has a frequency of 2, and '2' has a frequency of 3.\n\nExample 2:\n\nInput: nums = [2,3,1,3,2]\nOutput: [1,3,3,2,2]\nExplanation: '2' and '3' both have a frequency of 2, so they are sorted in decreasing order.\n\nExample 3:\n\nInput: nums = [-1,1,-6,4,5,-6,1,4,1]\nOutput: [5,-1,4,4,-6,-6,1,1,1]\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- -100 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 2, 2, 2, 3]) == [3, 1, 1, 2, 2, 2]\n assert candidate(nums = [10, 10, 20, 20, 30]) == [30, 20, 20, 10, 10]\n assert candidate(nums = [7, 7, 7, 6, 6, 5, 5, 5, 5]) == [6, 6, 7, 7, 7, 5, 5, 5, 5]\n assert candidate(nums = [5, 5, 4, 6, 4, 4, 4]) == [6, 5, 5, 4, 4, 4, 4]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]\n assert candidate(nums = [7, 7, 7, 8, 8, 9]) == [9, 8, 8, 7, 7, 7]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [-1, -1, -1, -2, -2, -3]) == [-3, -2, -2, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1]) == [1]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [2, 3, 1, 3, 2]) == [1, 3, 3, 2, 2]\n assert candidate(nums = [100, -100, 100, -100, 100]) == [-100, -100, 100, 100, 100]\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == [3, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0]\n assert candidate(nums = [100, -100, 0, 0, 0, 0]) == [100, -100, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 4, 4, 3, 3, 3, 3]) == [4, 4, 5, 5, 5, 3, 3, 3, 3]\n assert candidate(nums = [-100, 100]) == [100, -100]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]\n assert candidate(nums = [5, 5, 4, 4, 4, 6, 6, 6, 6]) == [5, 5, 4, 4, 4, 6, 6, 6, 6]\n assert candidate(nums = [-5, -5, -4, -4, -3, -3, -2, -2, -1, -1]) == [-1, -1, -2, -2, -3, -3, -4, -4, -5, -5]\n assert candidate(nums = [100, -100, 0, 0, 0]) == [100, -100, 0, 0, 0]\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 2, 2]) == [1, 1, 0, 0, 0, 2, 2, 2, 2]\n assert candidate(nums = [-1, 1, -6, 4, 5, -6, 1, 4, 1]) == [5, -1, 4, 4, -6, -6, 1, 1, 1]\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [4, 3, 2, 2, 1, 1, 1, 5, 5, 5, 5, 0, 0, 0, 0, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == [9, 8, 7, 6, 5, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 10, 10, 10, 10, 10]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9]) == [8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5]) == [9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == [12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == [0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [9, 8, 7, 6, 5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, 12, 12, -12, -12, -12]) == [100, 50, 25, -25, -50, -100, 12, 12, 12, -12, -12, -12]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [-1, -1, -1, -2, -2, -3, -3, -3, -3, -4, -4, -4, -4, -4, -5, -5, -5, -5, -5, -5]) == [-2, -2, -1, -1, -1, -3, -3, -3, -3, -4, -4, -4, -4, -4, -5, -5, -5, -5, -5, -5]\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99]) == [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == [10, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [7, 7, 7, 8, 8, 9, 9, 9, 9]) == [8, 8, 7, 7, 7, 9, 9, 9, 9]\n assert candidate(nums = [1, 1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8]) == [2, 3, 3, 1, 1, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11, 10, 9, 8, 8, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5]\n assert candidate(nums = [7, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 10, 10]) == [8, 8, 9, 9, 9, 7, 7, 7, 7, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [9, 8, 7, 6, 5, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [2, 2, 3, 3, 3, 1, 1, 1, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [-5, -5, -5, -5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3, 3]) == [3, 3, 2, 2, 1, 1, 0, 0, -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -5, -5]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]\n assert candidate(nums = [7, 7, 7, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10]) == [8, 8, 7, 7, 7, 9, 9, 9, 9, 10, 10, 10, 10, 10]\n assert candidate(nums = [7, 3, 7, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == [7, 7, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6, 3, -3, 1, -1, 0]) == [100, 50, 25, 12, 6, 3, 1, 0, -1, -3, -6, -12, -25, -50, -100]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1]\n assert candidate(nums = [15, 15, 15, 15, 20, 20, 20, 25, 25, 30, 30, 30, 30, 30, 35, 35]) == [35, 35, 25, 25, 20, 20, 20, 15, 15, 15, 15, 30, 30, 30, 30, 30]\n assert candidate(nums = [7, 7, 7, 7, 6, 6, 6, 5, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == [4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, 5, 5, 6, 6, 6, 7, 7, 7, 7]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6, -7, -7, -8, -8, -9, -9, -10, -10, -10]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]\n assert candidate(nums = [-5, -5, -5, -5, -4, -4, -3, -3, -2, -1, 0, 1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5]) == [2, 1, 0, -1, -2, 3, 3, -3, -3, -4, -4, 4, 4, 4, 5, 5, 5, 5, -5, -5, -5, -5]\n assert candidate(nums = [-10, -10, -10, -9, -9, -8, -8, -7, -6, -6, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -7, -8, -8, -9, -9, -6, -6, -6, -10, -10, -10]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == [2, 2, 1, 1, 1, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(nums = [100, -100, 100, 99, 99, 98, 98, 98, 97, 97, 97, 97]) == [-100, 100, 100, 99, 99, 98, 98, 98, 97, 97, 97, 97]\n assert candidate(nums = [5, 3, 8, 5, 8, 3, 9, 5, 3, 8, 8, 8, 8, 3, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [5, 5, 5, 3, 3, 3, 3, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5]) == [4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3]) == [3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [7, 7, 7, 3, 3, 5, 5, 5, 2, 2, 1]) == [1, 3, 3, 2, 2, 7, 7, 7, 5, 5, 5]\n assert candidate(nums = [0, -1, 0, -1, 0, -1, 1, 1, 1, 1, 1]) == [0, 0, 0, -1, -1, -1, 1, 1, 1, 1, 1]\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 100, 100, 90, 90, 80, 80, 70, 70, 60, 60, 50, 50, 40, 40, 30, 30, 20, 20, 10]) == [10, 10, 100, 100, 100, 90, 90, 90, 80, 80, 80, 70, 70, 70, 60, 60, 60, 50, 50, 50, 40, 40, 40, 30, 30, 30, 20, 20, 20]\n assert candidate(nums = [-1, -1, -1, -2, -2, -3, -3, -4, -4, -4, -5, -5, -5, -5, -5, -6, -6, -6, -6, -6, -6]) == [-2, -2, -3, -3, -1, -1, -1, -4, -4, -4, -5, -5, -5, -5, -5, -6, -6, -6, -6, -6, -6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == [50, 50, 50, 50, 50, 50, 40, 40, 40, 40, 40, 40, 30, 30, 30, 30, 30, 30, 20, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [10, 10, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40, 50]) == [50, 10, 10, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 6, 7]) == [7, 6, 5, 4, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0]\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100]) == [100, 100, 100, 100, 100, 100, 100, 100, -100, -100, -100, -100, -100, -100, -100, -100]\n assert candidate(nums = [100, -100, 100, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-100, 100, 100, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 0, 0, 0, 0, 0]) == [100, 50, 25, -25, -50, -100, 0, 0, 0, 0, 0]\n assert candidate(nums = [9, 8, 8, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4]) == [9, 8, 8, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1, 0, -1, -2, -2, -3, -3, -3, -4, -4, -4, -4, -5, -5, -5, -5, -5]) == [1, 0, -1, 2, 2, -2, -2, 3, 3, 3, -3, -3, -3, 4, 4, 4, 4, -4, -4, -4, -4, 5, 5, 5, 5, 5, -5, -5, -5, -5, -5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 10, 10, 10, 10]\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 75, -75, 0, 0, 0, 0, 0, 0]) == [100, 75, 50, 25, -25, -50, -75, -100, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == [2, 2, 1, 1, 1, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n assert candidate(nums = [10, 10, 10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60]) == [20, 20, 30, 30, 30, 10, 10, 10, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -5, -5, -5, -5]) == [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -5, -5, -5, -5]\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10]) == [50, 50, 50, 50, 40, 40, 40, 40, 30, 30, 30, 30, 20, 20, 20, 20, 10, 10, 10, 10, 10]\n assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50]) == [50, 50, 49, 49, 48, 48, 47, 47, 46, 46, 45, 45, 44, 44, 43, 43, 42, 42, 41, 41, 40, 40, 39, 39, 38, 38, 37, 37, 36, 36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [99, 99, 99, 99, 98, 98, 98, 97, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75]) == [96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 97, 97, 98, 98, 98, 99, 99, 99, 99]\n assert candidate(nums = [-5, -5, -5, -5, -5, -10, -10, -10, 0, 0, 0, 0, 0, 0, 0]) == [-10, -10, -10, -5, -5, -5, -5, -5, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == [2, 2, 3, 3, 3, 1, 1, 1, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(nums = [-1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6, -7, -7, -8, -8, -9, -9, -10, -10, -11, -11, -12, -12, -13, -13, -14, -14, -15, -15]) == [-1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6, -7, -7, -8, -8, -9, -9, -10, -10, -11, -11, -12, -12, -13, -13, -14, -14, -15, -15]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [0, 0, 0, 0, 0, -1, -1, -1, 1, 1, 1, 1, 1]) == [-1, -1, -1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 40, 40, 40, 40, 40, 40, 30, 30, 30, 20, 20, 10]) == [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [0, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, -1, -1]) == [1, 0, 2, 2, -1, -1, 3, 3, 3, 4, 4, 4, 4]\n", "comparison": "exact"}, "public_tests": ["[1,1,2,2,2,3]", "[2,3,1,3,2]", "[-1,1,-6,4,5,-6,1,4,1]"], "hints": ["Count the frequency of each value.", "Use a custom comparator to compare values by their frequency. If two values have the same frequency, compare their values."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().frequencySort", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:25:58+00:00", "tests_total": 117, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "hash-table", "sorting"]}, "language": "java", "interface": {"raw_signature": "public int[] frequencySort(int[] nums) {", "container": "Solution", "callable": "frequencySort", "parameters": [{"name": "nums", "type": "int[]"}], "return_type": "int[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1637, "task_id": "widest-vertical-area-between-two-points-containing-no-points", "difficulty": "Easy", "problem_description": "Given n points on a 2D plane where points[i] = [x_i, y_i], Return the widest vertical area between two points such that no points are inside the area.\n\nA vertical area is an area of fixed-width extending infinitely along the y-axis (i.e., infinite height). The widest vertical area is the one with the maximum width.\n\nNote that points on the edge of a vertical area are not considered included in the area.\n\nExample 1:\n\nInput: points = [[8,7],[9,9],[7,4],[9,7]]\nOutput: 1\nExplanation: Both the red and the blue area are optimal.\n\nExample 2:\n\nInput: points = [[3,1],[9,0],[1,0],[1,4],[5,3],[8,8]]\nOutput: 3\n\nConstraints:\n\n- n == points.length\n- 2 <= n <= 10^5\n- points[i].length == 2\n- 0 <= x_i, y_i <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 1\n assert candidate(points = [[1, 10], [3, 3], [5, 5], [7, 7], [9, 9]]) == 2\n assert candidate(points = [[5, 1], [4, 1], [3, 1], [2, 1], [1, 1]]) == 1\n assert candidate(points = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]]) == 10\n assert candidate(points = [[1, 1], [3, 3], [5, 5], [7, 7]]) == 2\n assert candidate(points = [[3, 1], [9, 0], [1, 0], [1, 4], [5, 3], [8, 8]]) == 3\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 1\n assert candidate(points = [[0, 0], [1000000000, 1000000000]]) == 1000000000\n assert candidate(points = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600]]) == 100\n assert candidate(points = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3]]) == 1\n assert candidate(points = [[8, 7], [9, 9], [7, 4], [9, 7]]) == 1\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == 10\n assert candidate(points = [[5, 5], [15, 5], [25, 5], [35, 5], [45, 5]]) == 10\n assert candidate(points = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14]]) == 3\n assert candidate(points = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]]) == 1\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40]]) == 10\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]]) == 100\n assert candidate(points = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512]]) == 256\n assert candidate(points = [[5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == 1\n assert candidate(points = [[1, 1], [1000000000, 1000000000], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 999999991\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [11, 110]]) == 1\n assert candidate(points = [[2, 5], [2, 8], [3, 6], [5, 9], [7, 10], [9, 3], [11, 7], [13, 4]]) == 2\n assert candidate(points = [[1, 10], [10, 1], [100, 10], [1000, 1], [10000, 10], [100000, 1], [1000000, 10], [10000000, 1], [100000000, 10], [1000000000, 1]]) == 900000000\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [10, 10], [20, 20], [30, 30], [40, 40]]) == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 1\n assert candidate(points = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9], [12, 11], [14, 13], [16, 15], [18, 17], [20, 19], [22, 21]]) == 2\n assert candidate(points = [[1, 999999999], [2, 999999998], [3, 999999997], [4, 999999996], [5, 999999995], [6, 999999994], [7, 999999993], [8, 999999992], [9, 999999991], [10, 999999990]]) == 1\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 1\n assert candidate(points = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [11, 1], [12, 2], [13, 3], [14, 4], [15, 5], [16, 6], [17, 7], [18, 8], [19, 9]]) == 1\n assert candidate(points = [[1, 5], [3, 5], [5, 5], [7, 5], [9, 5], [11, 5], [13, 5], [15, 5], [17, 5], [19, 5], [21, 5], [23, 5], [25, 5], [27, 5], [29, 5], [31, 5], [33, 5], [35, 5]]) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 1\n assert candidate(points = [[5, 2], [4, 3], [3, 4], [2, 5], [1, 6], [0, 7], [10, 8], [9, 9], [8, 10], [7, 11]]) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [5, 5], [8, 8], [13, 13], [21, 21], [34, 34], [55, 55], [89, 89], [144, 144], [233, 233], [377, 377]]) == 144\n assert candidate(points = [[2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]]) == 2\n assert candidate(points = [[1, 1], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8], [10, 11], [11, 10], [12, 13], [13, 12], [14, 15], [15, 14]]) == 1\n assert candidate(points = [[100, 1], [200, 1], [300, 1], [400, 1], [500, 1], [600, 1], [700, 1], [800, 1], [900, 1], [1000, 1]]) == 100\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600]]) == 100\n assert candidate(points = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19], [21, 21], [23, 23], [25, 25], [27, 27], [29, 29], [31, 31]]) == 2\n assert candidate(points = [[1, 1000000000], [1000000000, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 999999991\n assert candidate(points = [[1, 1], [10, 10], [100, 100], [1000, 1000], [10000, 10000], [100000, 100000], [1000000, 1000000], [10000000, 10000000], [100000000, 100000000], [1000000000, 1000000000], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 900000000\n assert candidate(points = [[1000000000, 10], [500000000, 20], [250000000, 30], [125000000, 40], [62500000, 50]]) == 500000000\n assert candidate(points = [[10, 10], [20, 25], [30, 30], [40, 45], [50, 50], [60, 65], [70, 70], [80, 85], [90, 90], [100, 105]]) == 10\n assert candidate(points = [[100, 1], [200, 1], [300, 1], [400, 1], [500, 1], [600, 1], [700, 1], [800, 1], [900, 1], [1000, 1]]) == 100\n assert candidate(points = [[10, 10], [100, 20], [1000, 30], [10000, 40], [100000, 50], [1000000, 60], [10000000, 70], [100000000, 80], [1000000000, 90]]) == 900000000\n assert candidate(points = [[5, 5], [10, 5], [15, 5], [20, 5], [25, 5], [30, 5], [35, 5], [40, 5], [45, 5], [50, 5]]) == 5\n assert candidate(points = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19], [21, 21], [23, 23], [25, 25]]) == 2\n assert candidate(points = [[1, 1], [1000000000, 1], [500000000, 1], [750000000, 1], [250000000, 1], [125000000, 1], [375000000, 1], [625000000, 1], [875000000, 1]]) == 125000000\n assert candidate(points = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10], [110, 10], [120, 10], [130, 10], [140, 10], [150, 10], [160, 10], [170, 10], [180, 10], [190, 10], [200, 10], [210, 10], [220, 10], [230, 10], [240, 10], [250, 10], [260, 10], [270, 10], [280, 10], [290, 10], [300, 10], [310, 10], [320, 10], [330, 10], [340, 10], [350, 10], [360, 10], [370, 10], [380, 10], [390, 10], [400, 10], [410, 10], [420, 10], [430, 10], [440, 10], [450, 10], [460, 10], [470, 10], [480, 10], [490, 10], [500, 10]]) == 10\n assert candidate(points = [[1, 2], [4, 6], [7, 8], [10, 5], [13, 9], [16, 3], [19, 7]]) == 3\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]]) == 2\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2]]) == 1\n assert candidate(points = [[1000000000, 1000000000], [999999999, 999999999], [999999998, 1000000000], [999999997, 999999999], [999999996, 1000000000], [999999995, 999999999], [999999994, 1000000000]]) == 1\n assert candidate(points = [[1, 10], [100, 100], [200, 100], [300, 100], [400, 100], [500, 100]]) == 100\n assert candidate(points = [[10, 20], [20, 10], [30, 30], [40, 20], [50, 10], [60, 30], [70, 20], [80, 10], [90, 30], [100, 20]]) == 10\n assert candidate(points = [[1, 2], [3, 4], [6, 5], [7, 8], [10, 9], [15, 1], [20, 6], [25, 3]]) == 5\n assert candidate(points = [[10, 1], [15, 2], [20, 3], [25, 4], [30, 5], [35, 6], [40, 7], [45, 8], [50, 9], [55, 10], [60, 11], [65, 12], [70, 13], [75, 14], [80, 15]]) == 5\n assert candidate(points = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110], [110, 120], [120, 130], [130, 140], [140, 150], [150, 160], [160, 170], [170, 180], [180, 190], [190, 200], [200, 210], [210, 220], [220, 230], [230, 240], [240, 250], [250, 260], [260, 270], [270, 280], [280, 290], [290, 300]]) == 10\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 1\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1]]) == 1\n assert candidate(points = [[100, 100], [101, 101], [102, 102], [200, 200], [201, 201], [300, 300], [301, 301]]) == 99\n assert candidate(points = [[1, 1], [10, 10], [100, 100], [1000, 1000], [10000, 10000], [100000, 100000], [1000000, 1000000], [10000000, 10000000], [100000000, 100000000]]) == 90000000\n assert candidate(points = [[10, 15], [25, 20], [5, 5], [35, 30], [40, 40], [50, 5], [60, 60], [75, 80], [80, 85], [90, 90]]) == 15\n assert candidate(points = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512], [1024, 1024]]) == 512\n assert candidate(points = [[0, 0], [0, 1], [0, 2], [0, 3], [1, 0], [1, 1], [1, 2], [1, 3], [2, 0], [2, 1], [2, 2], [2, 3]]) == 1\n assert candidate(points = [[1, 1], [1000000000, 1000000000], [2, 2], [999999999, 999999999], [3, 3], [999999998, 999999998]]) == 999999995\n assert candidate(points = [[1, 1], [1000000000, 1000000000], [500000000, 500000000], [250000000, 250000000], [750000000, 750000000]]) == 250000000\n assert candidate(points = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]]) == 1\n assert candidate(points = [[1, 9], [3, 8], [5, 7], [7, 6], [9, 5], [11, 4], [13, 3], [15, 2], [17, 1], [19, 0], [21, 9], [23, 8], [25, 7], [27, 6], [29, 5], [31, 4], [33, 3], [35, 2], [37, 1], [39, 0]]) == 2\n assert candidate(points = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [11, 9], [12, 8], [13, 7], [14, 6], [15, 5], [16, 4], [17, 3], [18, 2], [19, 1], [20, 0]]) == 1\n assert candidate(points = [[5, 5], [5, 1], [5, 9], [10, 10], [10, 5], [10, 0], [15, 15], [15, 10], [15, 0]]) == 5\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 2\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]]) == 0\n assert candidate(points = [[100, 200], [200, 200], [300, 200], [400, 200], [500, 200], [600, 200], [700, 200], [800, 200], [900, 200], [1000, 200]]) == 100\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500]]) == 50\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [10, 40], [11, 50], [20, 60], [21, 70]]) == 9\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]]) == 1\n assert candidate(points = [[1000000, 1], [2000000, 2], [3000000, 3], [4000000, 4], [5000000, 5], [6000000, 6], [7000000, 7], [8000000, 8], [9000000, 9], [10000000, 10]]) == 1000000\n assert candidate(points = [[1, 1], [1000000000, 1000000000], [500000000, 500000000], [250000000, 250000000], [750000000, 750000000], [125000000, 125000000], [625000000, 625000000], [375000000, 375000000], [875000000, 875000000]]) == 125000000\n assert candidate(points = [[10, 20], [30, 20], [20, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10]]) == 10\n assert candidate(points = [[500000000, 1], [500000001, 2], [500000002, 3], [500000003, 4], [500000004, 5]]) == 1\n assert candidate(points = [[1000000000, 0], [1000000000, 1000000000], [0, 0], [0, 1000000000], [500000000, 500000000]]) == 500000000\n assert candidate(points = [[1, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 1\n assert candidate(points = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95], [105, 105]]) == 10\n assert candidate(points = [[1, 1], [10, 2], [100, 3], [1000, 4], [10000, 5], [100000, 6], [1000000, 7], [10000000, 8], [100000000, 9], [1000000000, 10]]) == 900000000\n assert candidate(points = [[1, 5], [2, 3], [3, 1], [4, 4], [5, 7], [6, 2], [7, 6], [8, 8], [9, 9], [10, 0]]) == 1\n assert candidate(points = [[0, 0], [1000000000, 1000000000], [500000000, 500000000], [250000000, 250000000], [750000000, 750000000]]) == 250000000\n assert candidate(points = [[8, 1], [16, 2], [24, 3], [32, 4], [40, 5], [48, 6], [56, 7], [64, 8], [72, 9], [80, 10], [88, 11], [96, 12], [104, 13], [112, 14], [120, 15]]) == 8\n assert candidate(points = [[1, 10], [2, 20], [4, 30], [8, 40], [16, 50], [32, 60], [64, 70], [128, 80], [256, 90], [512, 100]]) == 256\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500], [550, 550], [600, 600]]) == 50\n assert candidate(points = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 11]]) == 10\n assert candidate(points = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [11, 9], [12, 8], [13, 7], [14, 6], [15, 5]]) == 1\n assert candidate(points = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512], [1024, 1024], [2048, 2048], [4096, 4096], [8192, 8192], [16384, 16384]]) == 8192\n assert candidate(points = [[5, 9], [5, 8], [5, 7], [5, 6], [5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [5, 0]]) == 0\n assert candidate(points = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 1], [70, 1], [80, 1], [90, 1], [100, 1]]) == 10\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 1]]) == 1\n assert candidate(points = [[1, 1], [10, 1], [100, 1], [1000, 1], [10000, 1], [100000, 1], [1000000, 1], [10000000, 1], [100000000, 1], [1000000000, 1]]) == 900000000\n assert candidate(points = [[1, 10], [1, 20], [1, 30], [1, 40], [1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [1, 100], [1, 110], [1, 120], [1, 130], [1, 140], [1, 150]]) == 0\n assert candidate(points = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 11], [120, 12], [130, 13], [140, 14], [150, 15]]) == 10\n assert candidate(points = [[8, 7], [9, 9], [7, 4], [9, 7], [11, 11], [12, 12], [10, 10], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18]]) == 1\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 1\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]]) == 1\n", "comparison": "exact"}, "public_tests": ["[[8,7],[9,9],[7,4],[9,7]]", "[[3,1],[9,0],[1,0],[1,4],[5,3],[8,8]]"], "hints": ["Try sorting the points", "Think whether the y-axis of a point is relevant"], "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().maxWidthOfVerticalArea", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:00+00:00", "tests_total": 104, "tests_dropped": 3, "flags": ["has_images"], "topic_tags": ["array", "sorting"]}, "language": "java", "interface": {"raw_signature": "public int maxWidthOfVerticalArea(int[][] points) {", "container": "Solution", "callable": "maxWidthOfVerticalArea", "parameters": [{"name": "points", "type": "int[][]"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}