diff --git "a/data/train/javascript-002.jsonl" "b/data/train/javascript-002.jsonl" --- "a/data/train/javascript-002.jsonl" +++ "b/data/train/javascript-002.jsonl" @@ -1,4 +1,3 @@ -{"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": "javascript", "interface": {"raw_signature": "var maxWidthOfVerticalArea = function(points) {", "container": null, "callable": "maxWidthOfVerticalArea", "parameters": [{"name": "points", "type": "number[][]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1638, "task_id": "count-substrings-that-differ-by-one-character", "difficulty": "Medium", "problem_description": "Given two strings s and t, find the number of ways you can choose a non-empty substring of s and replace a single character by a different character such that the resulting substring is a substring of t. In other words, find the number of substrings in s that differ from some substring in t by exactly one character.\n\nFor example, the underlined substrings in \"computer\" and \"computation\" only differ by the 'e'/'a', so this is a valid way.\n\nReturn the number of substrings that satisfy the condition above.\n\nA substring is a contiguous sequence of characters within a string.\n\nExample 1:\n\nInput: s = \"aba\", t = \"baba\"\nOutput: 6\nExplanation: The following are the pairs of substrings from s and t that differ by exactly 1 character:\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\nThe underlined portions are the substrings that are chosen from s and t.\n\nExample 2:\n\nInput: s = \"ab\", t = \"bb\"\nOutput: 3\nExplanation: The following are the pairs of substrings from s and t that differ by 1 character:\n(\"ab\", \"bb\")\n(\"ab\", \"bb\")\n(\"ab\", \"bb\")\nThe underlined portions are the substrings that are chosen from s and t.\n\nConstraints:\n\n- 1 <= s.length, t.length <= 100\n- s and t consist of lowercase English letters only.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abc\",t = \"abcd\") == 9\n assert candidate(s = \"abcde\",t = \"bcdef\") == 21\n assert candidate(s = \"aaaa\",t = \"bbbb\") == 16\n assert candidate(s = \"xyz\",t = \"xya\") == 9\n assert candidate(s = \"python\",t = \"typhon\") == 40\n assert candidate(s = \"xyz\",t = \"xyy\") == 9\n assert candidate(s = \"zzz\",t = \"zzz\") == 0\n assert candidate(s = \"same\",t = \"same\") == 12\n assert candidate(s = \"abcd\",t = \"abcf\") == 16\n assert candidate(s = \"abcde\",t = \"fghij\") == 25\n assert candidate(s = \"abcabc\",t = \"abcabc\") == 24\n assert candidate(s = \"aaaa\",t = \"aaab\") == 10\n assert candidate(s = \"mississippi\",t = \"misissippi\") == 126\n assert candidate(s = \"xyz\",t = \"xyw\") == 9\n assert candidate(s = \"a\",t = \"a\") == 0\n assert candidate(s = \"abcd\",t = \"dcba\") == 16\n assert candidate(s = \"abc\",t = \"def\") == 9\n assert candidate(s = \"a\",t = \"b\") == 1\n assert candidate(s = \"test\",t = \"tast\") == 16\n assert candidate(s = \"aba\",t = \"baba\") == 6\n assert candidate(s = \"aaa\",t = \"aaa\") == 0\n assert candidate(s = \"test\",t = \"text\") == 16\n assert candidate(s = \"abcd\",t = \"abce\") == 16\n assert candidate(s = \"hello\",t = \"hallo\") == 30\n assert candidate(s = \"code\",t = \"cide\") == 18\n assert candidate(s = \"ab\",t = \"bb\") == 3\n assert candidate(s = \"same\",t = \"sane\") == 18\n assert candidate(s = \"abcdefg\",t = \"abcdxyz\") == 49\n assert candidate(s = \"aaaaaab\",t = \"aaaaaac\") == 49\n assert candidate(s = \"qwertyuiop\",t = \"qwertuiopq\") == 99\n assert candidate(s = \"banana\",t = \"banane\") == 38\n assert candidate(s = \"asdfghjkl\",t = \"asdfghjkl\") == 72\n assert candidate(s = \"substring\",t = \"substrung\") == 94\n assert candidate(s = \"aaaaabbbbb\",t = \"bbbbbbaaaa\") == 91\n assert candidate(s = \"banana\",t = \"anana\") == 21\n assert candidate(s = \"algorithm\",t = \"algorihm\") == 72\n assert candidate(s = \"racecar\",t = \"racecdr\") == 55\n assert candidate(s = \"abacaba\",t = \"abacabb\") == 50\n assert candidate(s = \"aabbcc\",t = \"aabbcz\") == 41\n assert candidate(s = \"abcdefg\",t = \"gfedcba\") == 52\n assert candidate(s = \"aabbccddeeff\",t = \"aaabccddeeff\") == 177\n assert candidate(s = \"hellohello\",t = \"hellohelll\") == 101\n assert candidate(s = \"aabbccdd\",t = \"bbccddaa\") == 64\n assert candidate(s = \"racecar\",t = \"racecars\") == 52\n assert candidate(s = \"xyzxyzxyz\",t = \"zyxzyxzyx\") == 96\n assert candidate(s = \"programming\",t = \"programminh\") == 125\n assert candidate(s = \"banana\",t = \"bandana\") == 44\n assert candidate(s = \"abcdefg\",t = \"abcdefgh\") == 49\n assert candidate(s = \"qwert\",t = \"qwqrt\") == 29\n assert candidate(s = \"abcdefg\",t = \"abcdeff\") == 49\n assert candidate(s = \"abcdefghij\",t = \"abcdefghjk\") == 100\n assert candidate(s = \"abcabcabc\",t = \"abcabcabd\") == 72\n assert candidate(s = \"aaaaabbbbb\",t = \"aaaabbbbbb\") == 123\n assert candidate(s = \"abcdefghij\",t = \"abcdefghib\") == 100\n assert candidate(s = \"abcdefghi\",t = \"abcfghi\") == 63\n assert candidate(s = \"hellohello\",t = \"hallohallo\") == 134\n assert candidate(s = \"abcdefgh\",t = \"abcdefgha\") == 63\n assert candidate(s = \"qwert\",t = \"qwera\") == 25\n assert candidate(s = \"programming\",t = \"progrcmming\") == 150\n assert candidate(s = \"banana\",t = \"banama\") == 42\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",t = \"pneumonoultramicroscopicsilicovolcanoconiosus\") == 2250\n assert candidate(s = \"abcdabcd\",t = \"abceabcd\") == 72\n assert candidate(s = \"abcdefghij\",t = \"abcdefghix\") == 100\n assert candidate(s = \"example\",t = \"exampel\") == 48\n assert candidate(s = \"abcdefgh\",t = \"abxdefgh\") == 74\n assert candidate(s = \"abcabcabc\",t = \"defdefdef\") == 81\n assert candidate(s = \"programming\",t = \"prognamming\") == 149\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\") == 106\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",t = \"pneumonoultramicroscopicsilicovolcanoconiosi\") == 2118\n assert candidate(s = \"abcdef\",t = \"fedcba\") == 38\n assert candidate(s = \"abcdabcd\",t = \"dcbaabcd\") == 66\n assert candidate(s = \"abcdefgh\",t = \"fedcbagh\") == 68\n assert candidate(s = \"abcdefgh\",t = \"abcdexyz\") == 64\n assert candidate(s = \"abcdefg\",t = \"fghijkl\") == 47\n assert candidate(s = \"abcdefg\",t = \"abcdefh\") == 49\n assert candidate(s = \"abcdefghij\",t = \"abcdefghia\") == 99\n assert candidate(s = \"abcdef\",t = \"abcxef\") == 42\n assert candidate(s = \"abcdeabcde\",t = \"abcdeabcda\") == 94\n assert candidate(s = \"xyzzyx\",t = \"zyxzyx\") == 38\n assert candidate(s = \"zxcvbnm\",t = \"zxsvbnm\") == 57\n assert candidate(s = \"abcdabcd\",t = \"abxdabcd\") == 72\n assert candidate(s = \"mississippi\",t = \"misssissippi\") == 155\n assert candidate(s = \"longerstring\",t = \"longerstirng\") == 148\n assert candidate(s = \"pqrstuvw\",t = \"pqrsvwxy\") == 64\n assert candidate(s = \"zzzzzzzzzz\",t = \"zzzzzzzzza\") == 55\n assert candidate(s = \"abcdefg\",t = \"abcdefi\") == 49\n assert candidate(s = \"substring\",t = \"substrang\") == 93\n assert candidate(s = \"abacaba\",t = \"abaxaba\") == 56\n assert candidate(s = \"abcabcabc\",t = \"abcabcab\") == 48\n assert candidate(s = \"abcdefgh\",t = \"abcefgih\") == 67\n assert candidate(s = \"abcdefgabcdefg\",t = \"abcdefgabcdeff\") == 189\n assert candidate(s = \"python\",t = \"pythpn\") == 40\n assert candidate(s = \"abcdabcd\",t = \"abcddcba\") == 66\n assert candidate(s = \"abcdefg\",t = \"abcdefj\") == 49\n assert candidate(s = \"testtest\",t = \"tasttest\") == 68\n assert candidate(s = \"algorithm\",t = \"algorithr\") == 81\n assert candidate(s = \"aaaaab\",t = \"aaaabb\") == 35\n assert candidate(s = \"programming\",t = \"programming\") == 114\n assert candidate(s = \"banana\",t = \"bananas\") == 40\n assert candidate(s = \"testcase\",t = \"tastcase\") == 73\n assert candidate(s = \"aabbcc\",t = \"aabbbcc\") == 54\n assert candidate(s = \"qwertyuiop\",t = \"qwertuiop\") == 90\n assert candidate(s = \"programming\",t = \"programmimg\") == 136\n assert candidate(s = \"aabbccddeeff\",t = \"aabbccddeegg\") == 160\n assert candidate(s = \"abcdefg\",t = \"abcdefa\") == 48\n assert candidate(s = \"abcabcabc\",t = \"abcababc\") == 66\n assert candidate(s = \"abcabcabc\",t = \"abcabcbca\") == 71\n assert candidate(s = \"abcdefghij\",t = \"abcdefghja\") == 99\n assert candidate(s = \"testtest\",t = \"settsett\") == 83\n assert candidate(s = \"abcdefgh\",t = \"efghabcd\") == 56\n assert candidate(s = \"abacaba\",t = \"abacaba\") == 40\n assert candidate(s = \"abcdxyz\",t = \"xyzabcd\") == 42\n assert candidate(s = \"zzzzzz\",t = \"zzzzzz\") == 0\n assert candidate(s = \"pqrstuv\",t = \"qrsuvwp\") == 48\n assert candidate(s = \"abcabcabc\",t = \"ababcabc\") == 63\n assert candidate(s = \"abcdefghijk\",t = \"abcdefghijx\") == 121\n assert candidate(s = \"algorithm\",t = \"algorihtm\") == 83\n assert candidate(s = \"abcdabcd\",t = \"abacabad\") == 74\n assert candidate(s = \"zzzzz\",t = \"zzzzz\") == 0\n assert candidate(s = \"xyzz\",t = \"xyyz\") == 18\n assert candidate(s = \"banana\",t = \"bananna\") == 44\n assert candidate(s = \"aaaaabbbb\",t = \"aaaabbbbb\") == 98\n assert candidate(s = \"pattern\",t = \"patterr\") == 51\n assert candidate(s = \"abacax\",t = \"abacay\") == 40\n assert candidate(s = \"mississippi\",t = \"mississippa\") == 141\n assert candidate(s = \"programming\",t = \"progranning\") == 125\n assert candidate(s = \"substrings\",t = \"substraings\") == 108\n assert candidate(s = \"abcdefgh\",t = \"abcdefga\") == 63\n assert candidate(s = \"mississippi\",t = \"mississipp\") == 119\n assert candidate(s = \"zzzzzzzzzz\",t = \"zzzzzzzzzz\") == 0\n assert candidate(s = \"abcdefghij\",t = \"abcegijhif\") == 104\n assert candidate(s = \"aaaaaaaaaa\",t = \"bbbbbbbbbb\") == 100\n assert candidate(s = \"programming\",t = \"programminq\") == 125\n assert candidate(s = \"xyzzyx\",t = \"zyxzyz\") == 39\n assert candidate(s = \"aabbcc\",t = \"bbaacc\") == 38\n assert candidate(s = \"abcabcabcabc\",t = \"abababababab\") == 166\n assert candidate(s = \"mnopqr\",t = \"mnopqs\") == 36\n assert candidate(s = \"abacabadabacaba\",t = \"abacabadabacaba\") == 272\n assert candidate(s = \"racecar\",t = \"racecer\") == 56\n assert candidate(s = \"abacaba\",t = \"babcaba\") == 47\n assert candidate(s = \"abcdefgh\",t = \"abcdefgi\") == 64\n assert candidate(s = \"abababa\",t = \"bababab\") == 25\n assert candidate(s = \"abcd\",t = \"abdc\") == 16\n assert candidate(s = \"qwerty\",t = \"qwertyuiop\") == 54\n assert candidate(s = \"interview\",t = \"interviww\") == 89\n assert candidate(s = \"mississippi\",t = \"mississipxy\") == 140\n assert candidate(s = \"qwertyuiop\",t = \"poiuytrewq\") == 106\n assert candidate(s = \"abcdefg\",t = \"abacdef\") == 49\n assert candidate(s = \"abcdefg\",t = \"abcxefg\") == 58\n assert candidate(s = \"aaaaabbbbb\",t = \"aaaabbbbba\") == 128\n assert candidate(s = \"aaaaab\",t = \"aaabaa\") == 39\n assert candidate(s = \"aaaaaaab\",t = \"aaaaaaax\") == 64\n assert candidate(s = \"abcdefgh\",t = \"hgfedcba\") == 68\n assert candidate(s = \"abababab\",t = \"babababa\") == 32\n assert candidate(s = \"abcdef\",t = \"abcdeg\") == 36\n", "comparison": "exact"}, "public_tests": ["\"aba\"\n\"baba\"", "\"ab\"\n\"bb\""], "hints": ["Take every substring of s, change a character, and see how many substrings of t match that substring.", "Use a Trie to store all substrings of t as a dictionary."], "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().countSubstrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:02+00:00", "tests_total": 156, "tests_dropped": 1, "flags": [], "topic_tags": ["hash-table", "string", "dynamic-programming", "enumeration"]}, "language": "javascript", "interface": {"raw_signature": "var countSubstrings = function(s, t) {", "container": null, "callable": "countSubstrings", "parameters": [{"name": "s", "type": "string"}, {"name": "t", "type": "string"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1639, "task_id": "number-of-ways-to-form-a-target-string-given-a-dictionary", "difficulty": "Hard", "problem_description": "You are given a list of strings of the same length words and a string target.\n\nYour task is to form target using the given words under the following rules:\n\n- target should be formed from left to right.\n- To form the i^th character (0-indexed) of target, you can choose the k^th character of the j^th string in words if target[i] = words[j][k].\n- Once you use the k^th character of the j^th string of words, you can no longer use the x^th character of any string in words where x <= k. In other words, all characters to the left of or at index k become unusuable for every string.\n- Repeat the process until you form the string target.\n\nNotice that you can use multiple characters from the same string in words provided the conditions above are met.\n\nReturn the number of ways to form target from words. Since the answer may be too large, return it modulo 10^9 + 7.\n\nExample 1:\n\nInput: words = [\"acca\",\"bbbb\",\"caca\"], target = \"aba\"\nOutput: 6\nExplanation: There are 6 ways to form target.\n\"aba\" -> index 0 (\"acca\"), index 1 (\"bbbb\"), index 3 (\"caca\")\n\"aba\" -> index 0 (\"acca\"), index 2 (\"bbbb\"), index 3 (\"caca\")\n\"aba\" -> index 0 (\"acca\"), index 1 (\"bbbb\"), index 3 (\"acca\")\n\"aba\" -> index 0 (\"acca\"), index 2 (\"bbbb\"), index 3 (\"acca\")\n\"aba\" -> index 1 (\"caca\"), index 2 (\"bbbb\"), index 3 (\"acca\")\n\"aba\" -> index 1 (\"caca\"), index 2 (\"bbbb\"), index 3 (\"caca\")\n\nExample 2:\n\nInput: words = [\"abba\",\"baab\"], target = \"bab\"\nOutput: 4\nExplanation: There are 4 ways to form target.\n\"bab\" -> index 0 (\"baab\"), index 1 (\"baab\"), index 2 (\"abba\")\n\"bab\" -> index 0 (\"baab\"), index 1 (\"baab\"), index 3 (\"baab\")\n\"bab\" -> index 0 (\"baab\"), index 2 (\"baab\"), index 3 (\"baab\")\n\"bab\" -> index 1 (\"abba\"), index 2 (\"baab\"), index 3 (\"baab\")\n\nConstraints:\n\n- 1 <= words.length <= 1000\n- 1 <= words[i].length <= 1000\n- All strings in words have the same length.\n- 1 <= target.length <= 1000\n- words[i] and target contain only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['a', 'b', 'c'],target = \"abc\") == 0\n assert candidate(words = ['abc', 'def'],target = \"ad\") == 0\n assert candidate(words = ['mississippi'],target = \"issi\") == 15\n assert candidate(words = ['aaa', 'aaa', 'aaa'],target = \"aaa\") == 27\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'],target = \"abc\") == 8\n assert candidate(words = ['abc', 'bcd', 'cde'],target = \"abc\") == 1\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"miss\") == 567\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"issi\") == 1215\n assert candidate(words = ['acca', 'bbbb', 'caca'],target = \"aba\") == 6\n assert candidate(words = ['leetcode', 'leetcode', 'leetcode'],target = \"leet\") == 81\n assert candidate(words = ['aaa', 'aaa', 'aaa'],target = \"a\") == 9\n assert candidate(words = ['zzz', 'zzz', 'zzz'],target = \"zzz\") == 27\n assert candidate(words = ['abc', 'bcd', 'cde'],target = \"aab\") == 0\n assert candidate(words = ['abc', 'bcd', 'cde'],target = \"abd\") == 1\n assert candidate(words = ['aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa'],target = \"aaaa\") == 17010\n assert candidate(words = ['abc', 'def', 'ghi'],target = \"adg\") == 0\n assert candidate(words = ['abba', 'baab'],target = \"bab\") == 4\n assert candidate(words = ['mississippi'],target = \"sip\") == 12\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghijk\") == 0\n assert candidate(words = ['abcdef', 'bcadef', 'cdefgh'],target = \"abcd\") == 2\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"mnop\") == 1\n assert candidate(words = ['abcdefgh', 'ijklmnop', 'qrstuvwx', 'yzabcdef'],target = \"aceg\") == 1\n assert candidate(words = ['abcdefg', 'xyzabc', 'mnopqr', 'stuvwx'],target = \"abc\") == 4\n assert candidate(words = ['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd'],target = \"abcd\") == 15\n assert candidate(words = ['aaaa', 'bbbb', 'cccc', 'dddd'],target = \"abcd\") == 1\n assert candidate(words = ['xyzxyz', 'yzxyzy', 'zxyzxy', 'yzyxzy'],target = \"zyx\") == 26\n assert candidate(words = ['thisisanexample', 'thisisanexample', 'thisisanexample'],target = \"example\") == 2187\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi', 'mississippi'],target = \"miss\") == 1792\n assert candidate(words = ['hello', 'hello', 'hello', 'hello', 'hello'],target = \"hello\") == 3125\n assert candidate(words = ['xylophone', 'xylophone', 'xylophone'],target = \"xylo\") == 162\n assert candidate(words = ['hellohellohello', 'worldworldworld', 'hellohellohello'],target = \"helloworld\") == 2496\n assert candidate(words = ['ababababab', 'bababababa', 'ababababab'],target = \"ababab\") == 4339\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"aceg\") == 81\n assert candidate(words = ['lloremipsumdolorsitamet', 'lloremipsumdolorsitamet', 'lloremipsumdolorsitamet'],target = \"lorem\") == 1458\n assert candidate(words = ['abacabadabacaba', 'bacabadabacabab', 'acabadabacababa'],target = \"abacaba\") == 13252\n assert candidate(words = ['abcabc', 'bcabca', 'cababc'],target = \"abc\") == 39\n assert candidate(words = ['aabbccddeeff', 'bbaacceeddff', 'ccaabbeedddf', 'ddaabbccdeff'],target = \"abcde\") == 1496\n assert candidate(words = ['zzzz', 'zzzz', 'zzzz', 'zzzz', 'zzzz'],target = \"zz\") == 150\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"abcd\") == 5\n assert candidate(words = ['zzzzzz', 'yyyyyy', 'xxxxxx', 'wwwwww', 'vvvvvv'],target = \"zyxwv\") == 6\n assert candidate(words = ['abcabcabcabc', 'defdefdefdef', 'ghighighighi', 'jkljkljkljkl'],target = \"adgj\") == 1\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 999999937\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst'],target = \"afkp\") == 0\n assert candidate(words = ['zzzz', 'zzzz', 'zzzz', 'zzzz'],target = \"zzz\") == 256\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"ijkl\") == 1\n assert candidate(words = ['xyzxyzxyzxyz', 'yzxyzyzyzx', 'zxyzxyzxyz'],target = \"xyzxyz\") == 770\n assert candidate(words = ['aabbccddeeff', 'bbccddeeffgg', 'ccddeeffgghh'],target = \"abcdeffg\") == 414\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"acfi\") == 256\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"mnopqr\") == 1\n assert candidate(words = ['hello', 'hello', 'hello', 'hello', 'hello'],target = \"hello\") == 3125\n assert candidate(words = ['aabbcc', 'bbaacc', 'ccaabb'],target = \"abc\") == 40\n assert candidate(words = ['banana', 'banana', 'banana', 'banana'],target = \"ban\") == 192\n assert candidate(words = ['abcdefghi', 'jklmnopqr', 'stuvwxyz'],target = \"adgt\") == 0\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij'],target = \"abcde\") == 1\n assert candidate(words = ['abcabcabc', 'abcabcabc', 'abcabcabc'],target = \"abc\") == 270\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"mississippi\") == 177147\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi', 'mississippi', 'mississippi', 'mississippi'],target = \"issipi\") == 746496\n assert candidate(words = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz'],target = \"zzzz\") == 131250\n assert candidate(words = ['aabbcc', 'ddeeff', 'gghhii', 'jjkkll', 'mmnnoo'],target = \"abcd\") == 0\n assert candidate(words = ['aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa'],target = \"aaaa\") == 53760\n assert candidate(words = ['zzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzz'],target = \"zzzz\") == 392445\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"afg\") == 0\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"acegi\") == 3125\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij'],target = \"efghij\") == 1\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba'],target = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(words = ['abacaba', 'bacabab', 'cacabac', 'dacabad'],target = \"abac\") == 81\n assert candidate(words = ['zzzzzzzzzz', 'yyyyyyyyyy', 'xxxxxxxxxx', 'wwwwwwwwww', 'vvvvvvvvvv'],target = \"zyxwv\") == 252\n assert candidate(words = ['aaaaaaaaaa', 'bbbbbbbbbb', 'cccccccccc'],target = \"abc\") == 120\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij'],target = \"defg\") == 15\n assert candidate(words = ['target', 'target', 'target', 'target', 'target'],target = \"target\") == 15625\n assert candidate(words = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'jihgfedcba'],target = \"abcdefghij\") == 1024\n assert candidate(words = ['abcdefghij', 'klmnopqr', 'stuvwxyz', 'abcdefghij', 'klmnopqr'],target = \"mnop\") == 16\n assert candidate(words = ['banana', 'banana', 'banana', 'banana', 'banana'],target = \"ban\") == 375\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 59049\n assert candidate(words = ['aaaa', 'abbb', 'accc', 'addd'],target = \"abcd\") == 4\n assert candidate(words = ['aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz', 'aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz'],target = \"abcdefghijklmnopqrstu\") == 46480318\n assert candidate(words = ['abcdefg', 'abcdefg', 'abcdefg', 'abcdefg', 'abcdefg'],target = \"abcdefg\") == 78125\n assert candidate(words = ['abcdefghijklmnop', 'qrstuvwxyzab', 'cdefghijklmnop', 'qrstuvwxyzab'],target = \"abcde\") == 1\n assert candidate(words = ['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd'],target = \"abcd\") == 15\n assert candidate(words = ['abcdefghijk', 'abcdefghij', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc'],target = \"abcdefg\") == 1224720\n assert candidate(words = ['aabbccdd', 'aabbccdd', 'aabbccdd', 'aabbccdd'],target = \"abcd\") == 4096\n assert candidate(words = ['abcd', 'abcf', 'acdf', 'adef'],target = \"ace\") == 4\n assert candidate(words = ['abcdefghij', 'klmnopqr', 'stuvwxyz', 'abcdefghij', 'klmnopqr'],target = \"mnopqrst\") == 0\n assert candidate(words = ['aaaaaaaabaaaaaa', 'baaaaaaaabaaaaa', 'caaaaaaabaaaaaa'],target = \"aaaaaabaaaaaa\") == 9920232\n assert candidate(words = ['abacabadabacaba', 'bcbdbecbdbecb', 'dcdcdcddcdcdc'],target = \"abc\") == 110\n assert candidate(words = ['abababababababab', 'bababababababa', 'abababababababab'],target = \"abab\") == 9394\n assert candidate(words = ['abcdef', 'fedcba', 'abcdef'],target = \"abcdef\") == 64\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"stuvwx\") == 1\n assert candidate(words = ['qwerty', 'qwerty', 'qwerty', 'qwerty', 'qwerty'],target = \"qwe\") == 125\n assert candidate(words = ['abcabcabc', 'defdefdef', 'ghighighi'],target = \"adg\") == 1\n assert candidate(words = ['abcdefghijk', 'abcdefghij', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc'],target = \"abc\") == 729\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghijabcdefghij\") == 0\n assert candidate(words = ['aabbcc', 'ddeeff', 'gghhii', 'jjkkgg'],target = \"abgi\") == 4\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba'],target = \"zyxwvutsrqponmlkjihgfedcba\") == 67108864\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyz'],target = \"abcdefghijklmnopqrstuvwxyz\") == 67108864\n assert candidate(words = ['aaaa', 'abab', 'acac', 'adad', 'aeae'],target = \"aa\") == 46\n assert candidate(words = ['programming', 'is', 'fun'],target = \"pin\") == 1\n assert candidate(words = ['sequence', 'sequence', 'sequence', 'sequence', 'sequence'],target = \"seq\") == 125\n assert candidate(words = ['abcd', 'abcd', 'abcd', 'abcd', 'abcd'],target = \"abcd\") == 625\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"ssss\") == 81\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"abc\") == 4\n assert candidate(words = ['abcdefghijkl', 'mnopqrstuv', 'wxyzabcdef', 'ghijklmnop'],target = \"mnop\") == 5\n assert candidate(words = ['abcdefghijabcdefghij', 'jihgfedcbaabcdef', 'abcdefghijjihgfe'],target = \"abcdefghij\") == 3536\n assert candidate(words = ['abacaba', 'bcbcbcb', 'cacacac'],target = \"abcabc\") == 10\n assert candidate(words = ['aabbccddeeff', 'gghhiijjkkll', 'mmnnooppqqrr', 'ssttuuvvwwxx'],target = \"abcdefff\") == 0\n assert candidate(words = ['abcde', 'abfgh', 'acjkl'],target = \"abac\") == 0\n assert candidate(words = ['algorithm', 'algorithm', 'algorithm', 'algorithm', 'algorithm'],target = \"algo\") == 625\n assert candidate(words = ['aaaaaaaaaa', 'aaaaaaaaab', 'aaaaaaaaac', 'aaaaaaaaad'],target = \"aaa\") == 5952\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"yzabcd\") == 1\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 9765625\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"abcde\") == 1\n assert candidate(words = ['abcdefg', 'bcdefgh', 'cdefghi'],target = \"efg\") == 10\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 9765625\n assert candidate(words = ['racecar', 'racecar', 'racecar', 'racecar', 'racecar'],target = \"race\") == 625\n assert candidate(words = ['zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'],target = \"zzzzzzzzzz\") == 277520636\n assert candidate(words = ['abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd'],target = \"abcdabcd\") == 0\n assert candidate(words = ['abcabcabcabc', 'bcabcabcabca', 'cabcabcabcab'],target = \"abcabc\") == 924\n assert candidate(words = ['aabbccdd', 'bbaaddcc', 'ccddaabb', 'ddbbaacc'],target = \"abcd\") == 77\n assert candidate(words = ['aaaaaaaaa', 'bbbbbbbbb', 'ccccccccc', 'ddddddddd', 'eeeeeeeee', 'fffffff', 'ggggggggg', 'hhhhhhhhh', 'iiiiiiiii'],target = \"abcdefghi\") == 1\n assert candidate(words = ['zzzzzz', 'zzzzzz', 'zzzzzz'],target = \"zzz\") == 540\n assert candidate(words = ['quickbrownfox', 'quickbrownfox', 'quickbrownfox'],target = \"quickfox\") == 6561\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 59049\n assert candidate(words = ['abacabadabacaba', 'bcbdbecbdbecb', 'dcdcdcddcdcdc', 'efefegfefegfe', 'ghighighihighi'],target = \"abcdefg\") == 40\n assert candidate(words = ['abcdabcdabcd', 'abcdabcdabcd', 'abcdabcdabcd'],target = \"abcd\") == 1215\n assert candidate(words = ['abcdabcdabcd', 'bcdbcdbcdb', 'cdcdcdcdcd'],target = \"abcdabcd\") == 184\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"abcdef\") == 1\n assert candidate(words = ['abcabcabc', 'defdefdef', 'ghighighi'],target = \"adg\") == 1\n assert candidate(words = ['abcdefg', 'hijklmn', 'opqrstu', 'vwxyzab', 'cdefghi'],target = \"abcde\") == 1\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr'],target = \"abcghi\") == 0\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'zabcd'],target = \"ace\") == 4\n assert candidate(words = ['aaaaaaaaaa', 'bbbbbbbbbb', 'cccccccccc', 'dddddddddd', 'eeeeeeeeee'],target = \"abcde\") == 252\n assert candidate(words = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz'],target = \"zzz\") == 7680\n assert candidate(words = ['aabbcc', 'ddeeff', 'gghhii', 'jjkkll'],target = \"abcd\") == 0\n assert candidate(words = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee'],target = \"abcde\") == 1\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"efgh\") == 5\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],target = \"zyxwvut\") == 0\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst'],target = \"afk\") == 0\n assert candidate(words = ['leetcode', 'leetcode', 'leetcode', 'leetcode'],target = \"leet\") == 256\n assert candidate(words = ['abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh'],target = \"abcdefgh\") == 390625\n assert candidate(words = ['thisisalongstring', 'thisisalongstring', 'thisisalongstring', 'thisisalongstring'],target = \"thisisalongstring\") == 179869065\n assert candidate(words = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz'],target = \"zzzz\") == 53760\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"afik\") == 0\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 1048576\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abc\") == 125\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"missi\") == 3645\n assert candidate(words = ['abracadabra', 'abracadabra', 'abracadabra', 'abracadabra'],target = \"abrac\") == 1024\n assert candidate(words = ['ababababab', 'bababababa', 'ababababab', 'bababababa'],target = \"abab\") == 3360\n assert candidate(words = ['xylophone', 'xylophone', 'xylophone', 'xylophone', 'xylophone'],target = \"xyl\") == 125\n", "comparison": "exact"}, "public_tests": ["[\"acca\",\"bbbb\",\"caca\"]\n\"aba\"", "[\"abba\",\"baab\"]\n\"bab\""], "hints": ["For each index i, store the frequency of each character in the ith row.", "Use dynamic programing to calculate the number of ways to get the target string using the frequency array."], "metadata": {"canonical_parameter_names": ["words", "target"], "leetcode_dataset_entry_point": "Solution().numWays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:05+00:00", "tests_total": 148, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "string", "dynamic-programming"]}, "language": "javascript", "interface": {"raw_signature": "var numWays = function(words, target) {", "container": null, "callable": "numWays", "parameters": [{"name": "words", "type": "string[]"}, {"name": "target", "type": "string"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1640, "task_id": "check-array-formation-through-concatenation", "difficulty": "Easy", "problem_description": "You are given an array of distinct integers arr and an array of integer arrays pieces, where the integers in pieces are distinct. Your goal is to form arr by concatenating the arrays in pieces in any order. However, you are not allowed to reorder the integers in each array pieces[i].\n\nReturn true if it is possible to form the array arr from pieces. Otherwise, return false.\n\nExample 1:\n\nInput: arr = [15,88], pieces = [[88],[15]]\nOutput: true\nExplanation: Concatenate [15] then [88]\n\nExample 2:\n\nInput: arr = [49,18,16], pieces = [[16,18,49]]\nOutput: false\nExplanation: Even though the numbers match, we cannot reorder pieces[0].\n\nExample 3:\n\nInput: arr = [91,4,64,78], pieces = [[78],[4,64],[91]]\nOutput: true\nExplanation: Concatenate [91] then [4,64] then [78]\n\nConstraints:\n\n- 1 <= pieces.length <= arr.length <= 100\n- sum(pieces[i].length) == arr.length\n- 1 <= pieces[i].length <= arr.length\n- 1 <= arr[i], pieces[i][j] <= 100\n- The integers in arr are distinct.\n- The integers in pieces are distinct (i.e., If we flatten pieces in a 1D array, all the integers in this array are distinct).\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [10, 20, 30, 40, 50],pieces = [[10, 20], [30, 40, 50]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5],pieces = [[2, 3], [1, 4], [5]]) == False\n assert candidate(arr = [91, 4, 64, 78],pieces = [[78], [4, 64], [91]]) == True\n assert candidate(arr = [49, 18, 16],pieces = [[16, 18, 49]]) == False\n assert candidate(arr = [15, 88],pieces = [[88], [15]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5],pieces = [[2], [4, 5], [3], [1]]) == True\n assert candidate(arr = [5, 9, 13, 17, 21, 25],pieces = [[5, 9, 13], [17, 21, 25]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14],pieces = [[2, 4], [6, 8], [10, 12], [14]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],pieces = [[100, 99], [98, 97], [96, 95, 94], [93, 92], [91]]) == True\n assert candidate(arr = [91, 4, 64, 78, 100, 50],pieces = [[78, 100], [91, 4], [64], [50]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],pieces = [[1, 3, 5, 7], [9, 11], [13, 15, 17, 19], [21, 23, 25], [27, 29]]) == True\n assert candidate(arr = [8, 16, 24, 32, 40, 48, 56, 64],pieces = [[8, 16, 24], [32, 40, 48], [56, 64]]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99],pieces = [[11, 22], [33, 44, 55], [66, 77, 88, 99]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40],pieces = [[5, 10, 15], [20, 25], [30, 35, 40]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pieces = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pieces = [[1, 3, 5], [7, 9, 11], [13, 15, 17, 19]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2, 3], [4, 5], [6, 7, 8, 9, 10]]) == True\n assert candidate(arr = [23, 32, 45, 54, 67, 76, 89, 98],pieces = [[23, 32], [45, 54, 67], [76, 89], [98]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pieces = [[1, 3], [5, 7, 9], [11, 13], [15, 17, 19]]) == True\n assert candidate(arr = [3, 1, 2, 5, 4],pieces = [[3, 1], [2, 5], [4]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9],pieces = [[1, 2], [3, 4, 5], [6], [7, 8, 9]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pieces = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],pieces = [[100, 99], [98, 97, 96], [95, 94, 93], [92, 91]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pieces = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11], [12, 13, 14, 15]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pieces = [[2, 4], [6, 8, 10], [12, 14], [16, 18, 20]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pieces = [[1, 2, 3], [4, 5], [6, 7, 8], [9, 10, 11], [12, 13, 14, 15]]) == True\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],pieces = [[9], [8], [7], [6], [5], [4], [3], [2], [1]]) == True\n assert candidate(arr = [42, 13, 56, 78, 91, 100],pieces = [[42], [13, 56], [78], [91, 100]]) == True\n assert candidate(arr = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30],pieces = [[21, 22], [23, 24], [25, 26], [27, 28], [29, 30]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90],pieces = [[10, 20, 30], [40, 50], [60, 70, 80, 90]]) == True\n assert candidate(arr = [12, 14, 16, 18, 20, 22, 24, 26, 28, 30],pieces = [[12, 14, 16], [18, 20], [22, 24, 26, 28, 30]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == True\n assert candidate(arr = [99, 88, 77, 66, 55, 44, 33, 22, 11],pieces = [[99], [88], [77], [66], [55], [44], [33], [22], [11]]) == True\n assert candidate(arr = [20, 30, 10, 50, 40],pieces = [[20, 30], [10, 50], [40]]) == True\n assert candidate(arr = [7, 14, 28, 21, 42],pieces = [[7, 14, 28], [21, 42]]) == True\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],pieces = [[100, 90], [80, 70, 60, 50], [40, 30, 20, 10]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[3, 4], [1, 2], [7, 8], [5, 6], [9, 10]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],pieces = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) == True\n assert candidate(arr = [42, 43, 44, 45, 46, 47, 48, 49, 50],pieces = [[42, 43], [44, 45, 46], [47, 48], [49, 50]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pieces = [[1, 3, 5], [7, 9], [11, 13], [15, 17, 19]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40],pieces = [[5], [10, 15], [20, 25, 30], [35, 40]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15],pieces = [[1, 3, 5], [7, 9], [11, 13, 15]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pieces = [[1], [3, 5], [7, 9], [11, 13], [15, 17, 19]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90],pieces = [[10], [20], [30], [40], [50], [60], [70], [80], [90]]) == True\n assert candidate(arr = [2, 5, 3, 8, 9, 4],pieces = [[2, 5], [3], [8, 9], [4]]) == True\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],pieces = [[99, 98, 97], [96, 95, 94], [93, 92, 91, 90]]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27],pieces = [[3, 6, 9], [12, 15], [18, 21, 24, 27]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9],pieces = [[1, 2], [3, 4, 5], [6, 7, 8], [9]]) == True\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15],pieces = [[3, 5, 7], [9, 11], [13, 15]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2], [3, 4, 5], [6, 7], [8, 9, 10]]) == True\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15],pieces = [[3, 5, 7], [9], [11, 13, 15]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96],pieces = [[97, 98], [96], [99], [100]]) == False\n assert candidate(arr = [7, 14, 21, 28, 35, 42],pieces = [[7], [14], [21], [28], [35], [42]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30],pieces = [[10, 15], [5], [20, 25, 30]]) == True\n assert candidate(arr = [5, 6, 1, 2, 3, 4],pieces = [[5, 6], [1, 2], [3, 4]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95],pieces = [[100], [99, 98], [97, 96, 95]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2], [3, 4, 5], [6, 7, 8, 9, 10]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95],pieces = [[100, 99], [98, 97], [96, 95]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],pieces = [[1, 3, 5], [7, 9, 11], [13, 15, 17], [19, 21]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35],pieces = [[5, 10, 15], [20], [25, 30, 35]]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99],pieces = [[11, 22, 33], [44, 55], [66, 77, 88, 99]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70],pieces = [[10, 20], [30, 40, 50], [60, 70]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pieces = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == True\n assert candidate(arr = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34],pieces = [[25, 26], [27, 28, 29], [30, 31, 32, 33], [34]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],pieces = [[5, 10, 15], [20, 25, 30], [35, 40, 45], [50]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16],pieces = [[2, 4], [6, 8, 10], [12, 14, 16]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pieces = [[2, 4], [6, 8, 10], [12, 14], [16, 18, 20]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pieces = [[2, 4, 6], [8, 10, 12], [14, 16, 18], [20]]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21],pieces = [[3, 6], [9, 12], [15, 18], [21]]) == True\n assert candidate(arr = [5, 4, 3, 2, 1],pieces = [[5], [4, 3], [2, 1]]) == True\n assert candidate(arr = [31, 32, 33, 34, 35, 36, 37, 38, 39, 40],pieces = [[31, 32], [33, 34], [35, 36], [37, 38], [39, 40]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],pieces = [[100, 99], [98, 97], [96, 95], [94, 93], [92, 91]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pieces = [[2, 4, 6], [8, 10], [12, 14, 16, 18, 20]]) == True\n assert candidate(arr = [23, 29, 20, 32, 45, 67],pieces = [[23, 29, 20], [32], [45, 67]]) == True\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56],pieces = [[7, 14, 21, 28], [35, 42], [49, 56]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9],pieces = [[1, 2], [3, 4], [5, 6], [7, 8], [9]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],pieces = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]]) == True\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],pieces = [[9, 8, 7], [6, 5], [4, 3, 2], [1]]) == True\n assert candidate(arr = [5, 1, 3, 7, 8, 2, 4, 9, 6],pieces = [[1, 3], [5], [7, 8], [2, 4], [9, 6]]) == True\n assert candidate(arr = [5, 3, 8, 9, 10, 15, 20],pieces = [[5], [3, 8, 9], [10, 15], [20]]) == True\n assert candidate(arr = [4, 2, 5, 3, 6, 1, 7],pieces = [[4, 2], [5], [3, 6], [1, 7]]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99],pieces = [[11, 22], [33, 44], [55, 66], [77, 88, 99]]) == True\n assert candidate(arr = [42, 24, 66, 33, 55, 77],pieces = [[42], [24, 66], [33, 55], [77]]) == True\n assert candidate(arr = [5, 1, 3, 9, 7, 6],pieces = [[5, 1], [3, 9], [7, 6]]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 100],pieces = [[11, 22], [33, 44], [55, 66], [77, 88], [99, 100]]) == True\n assert candidate(arr = [23, 45, 67, 89, 90, 12, 34, 56],pieces = [[23, 45], [67, 89, 90], [12, 34, 56]]) == True\n", "comparison": "exact"}, "public_tests": ["[15,88]\n[[88],[15]]", "[49,18,16]\n[[16,18,49]]", "[91,4,64,78]\n[[78],[4,64],[91]]"], "hints": ["Note that the distinct part means that every position in the array belongs to only one piece", "Note that you can get the piece every position belongs to naively"], "metadata": {"canonical_parameter_names": ["arr", "pieces"], "leetcode_dataset_entry_point": "Solution().canFormArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:26:07+00:00", "tests_total": 99, "tests_dropped": 11, "flags": [], "topic_tags": ["array", "hash-table"]}, "language": "javascript", "interface": {"raw_signature": "var canFormArray = function(arr, pieces) {", "container": null, "callable": "canFormArray", "parameters": [{"name": "arr", "type": "number[]"}, {"name": "pieces", "type": "number[][]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} @@ -99,7 +98,7 @@ {"question_id": 1773, "task_id": "count-items-matching-a-rule", "difficulty": "Easy", "problem_description": "You are given an array items, where each items[i] = [type_i, color_i, name_i] describes the type, color, and name of the i^th item. You are also given a rule represented by two strings, ruleKey and ruleValue.\n\nThe i^th item is said to match the rule if one of the following is true:\n\n- ruleKey == \"type\" and ruleValue == type_i.\n- ruleKey == \"color\" and ruleValue == color_i.\n- ruleKey == \"name\" and ruleValue == name_i.\n\nReturn the number of items that match the given rule.\n\nExample 1:\n\nInput: items = [[\"phone\",\"blue\",\"pixel\"],[\"computer\",\"silver\",\"lenovo\"],[\"phone\",\"gold\",\"iphone\"]], ruleKey = \"color\", ruleValue = \"silver\"\nOutput: 1\nExplanation: There is only one item matching the given rule, which is [\"computer\",\"silver\",\"lenovo\"].\n\nExample 2:\n\nInput: items = [[\"phone\",\"blue\",\"pixel\"],[\"computer\",\"silver\",\"phone\"],[\"phone\",\"gold\",\"iphone\"]], ruleKey = \"type\", ruleValue = \"phone\"\nOutput: 2\nExplanation: There are only two items matching the given rule, which are [\"phone\",\"blue\",\"pixel\"] and [\"phone\",\"gold\",\"iphone\"]. Note that the item [\"computer\",\"silver\",\"phone\"] does not match.\n\nConstraints:\n\n- 1 <= items.length <= 10^4\n- 1 <= type_i.length, color_i.length, name_i.length, ruleValue.length <= 10\n- ruleKey is equal to either \"type\", \"color\", or \"name\".\n- All strings consist only of lowercase letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'harley'], ['car', 'green', 'lambo']],ruleKey = \"color\",ruleValue = \"red\") == 1\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'phone'], ['phone', 'gold', 'iphone']],ruleKey = \"type\",ruleValue = \"phone\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['phone', 'black', 'samsung'], ['tablet', 'black', 'ipad']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['laptop', 'black', 'dell'], ['phone', 'white', 'samsung'], ['tablet', 'gray', 'apple']],ruleKey = \"name\",ruleValue = \"apple\") == 1\n assert candidate(items = [['laptop', 'black', 'dell'], ['tablet', 'white', 'samsung'], ['laptop', 'silver', 'macbook']],ruleKey = \"name\",ruleValue = \"dell\") == 1\n assert candidate(items = [['shoe', 'white', 'nike'], ['shirt', 'black', 'adidas'], ['shoe', 'black', 'puma']],ruleKey = \"type\",ruleValue = \"shoe\") == 2\n assert candidate(items = [['book', 'red', 'novel'], ['pen', 'blue', 'ballpoint'], ['notebook', 'red', 'blank']],ruleKey = \"name\",ruleValue = \"blank\") == 1\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'lenovo'], ['phone', 'gold', 'iphone']],ruleKey = \"color\",ruleValue = \"silver\") == 1\n assert candidate(items = [['laptop', 'black', 'dell'], ['laptop', 'gray', 'hp'], ['desktop', 'black', 'asus']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['book', 'brown', 'alice'], ['pen', 'blue', 'bic'], ['notebook', 'white', 'staples']],ruleKey = \"type\",ruleValue = \"book\") == 1\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'red', 'yamaha'], ['truck', 'blue', 'ford']],ruleKey = \"type\",ruleValue = \"red\") == 0\n assert candidate(items = [['book', 'red', 'novel'], ['pen', 'blue', 'ballpoint'], ['book', 'brown', 'textbook']],ruleKey = \"type\",ruleValue = \"book\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['camera', 'black', 'canon'], ['camera', 'silver', 'nikon'], ['camera', 'black', 'sony'], ['camera', 'gold', 'fujifilm'], ['camera', 'black', 'olympus']],ruleKey = \"name\",ruleValue = \"sony\") == 1\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'blue', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'black', 'apple'], ['smartphone', 'red', 'motorola']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['toys', 'yellow', 'balloon'], ['toys', 'red', 'car'], ['toys', 'blue', 'doll'], ['toys', 'green', 'teddy'], ['toys', 'yellow', 'block']],ruleKey = \"color\",ruleValue = \"yellow\") == 2\n assert candidate(items = [['computer', 'silver', 'dell'], ['computer', 'black', 'apple'], ['computer', 'silver', 'hp'], ['computer', 'black', 'asus'], ['computer', 'silver', 'lenovo'], ['computer', 'black', 'microsoft']],ruleKey = \"color\",ruleValue = \"silver\") == 3\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'blue', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'black', 'apple'], ['laptop', 'gray', 'hp']],ruleKey = \"type\",ruleValue = \"laptop\") == 2\n assert candidate(items = [['shirt', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shoes', 'blue', 'puma'], ['hat', 'blue', 'reebok'], ['shirt', 'blue', 'nike']],ruleKey = \"name\",ruleValue = \"nike\") == 2\n assert candidate(items = [['chair', 'brown', 'ikea'], ['table', 'white', 'ikea'], ['couch', 'gray', 'ikea'], ['desk', 'black', 'ikea'], ['lamp', 'silver', 'ikea']],ruleKey = \"brand\",ruleValue = \"ikea\") == 5\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'gold', 'fitbit'], ['laptop', 'gray', 'hp']],ruleKey = \"type\",ruleValue = \"laptop\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'gold', 'fitbit'], ['laptop', 'gray', 'hp'], ['laptop', 'black', 'macbook']],ruleKey = \"type\",ruleValue = \"laptop\") == 3\n assert candidate(items = [['book', 'blue', 'fiction'], ['book', 'red', 'nonfiction'], ['book', 'blue', 'science'], ['book', 'green', 'history'], ['book', 'blue', 'fantasy']],ruleKey = \"name\",ruleValue = \"nonfiction\") == 1\n assert candidate(items = [['chair', 'white', 'ikea'], ['sofa', 'brown', 'ikea'], ['table', 'brown', 'ikea'], ['lamp', 'white', 'ikea'], ['shelf', 'brown', 'ikea'], ['cabinet', 'white', 'ikea']],ruleKey = \"type\",ruleValue = \"ikea\") == 0\n assert candidate(items = [['apparel', 'black', 'jacket'], ['apparel', 'white', 'shirt'], ['apparel', 'red', 'pants'], ['apparel', 'blue', 'hat']],ruleKey = \"type\",ruleValue = \"apparel\") == 4\n assert candidate(items = [['camera', 'black', 'nikon'], ['camera', 'silver', 'canon'], ['camera', 'gold', 'leica'], ['camera', 'black', 'olympus'], ['camera', 'white', 'fujifilm']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['toy', 'green', 'car'], ['toy', 'red', 'doll'], ['toy', 'blue', 'block'], ['toy', 'green', 'train'], ['toy', 'red', 'helicopter'], ['toy', 'blue', 'truck']],ruleKey = \"type\",ruleValue = \"toy\") == 6\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'lenovo'], ['phone', 'gold', 'iphone'], ['tablet', 'black', 'samsung'], ['smartwatch', 'black', 'fitbit'], ['laptop', 'blue', 'macbook']],ruleKey = \"color\",ruleValue = \"blue\") == 2\n assert candidate(items = [['smartphone', 'red', 'iphone'], ['smartphone', 'black', 'galaxy'], ['smartphone', 'white', 'nokia'], ['smartphone', 'black', 'oneplus'], ['smartphone', 'red', 'motorola'], ['smartphone', 'blue', 'huawei'], ['smartphone', 'red', 'oppo'], ['smartphone', 'green', 'realme']],ruleKey = \"name\",ruleValue = \"red\") == 0\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'gold', 'fitbit'], ['laptop', 'gray', 'hp'], ['laptop', 'black', 'macbook'], ['laptop', 'gray', 'asus']],ruleKey = \"name\",ruleValue = \"laptop\") == 0\n assert candidate(items = [['house', 'white', 'mansions'], ['house', 'blue', 'cottages'], ['apartment', 'gray', 'flats'], ['condo', 'white', 'duplex'], ['townhouse', 'blue', 'terraced'], ['house', 'white', 'bungalows'], ['apartment', 'gray', 'penthouse'], ['condo', 'blue', 'villa'], ['townhouse', 'white', 'villas'], ['house', 'gray', 'detached']],ruleKey = \"type\",ruleValue = \"house\") == 4\n assert candidate(items = [['smartphone', 'red', 'iphone'], ['smartphone', 'black', 'galaxy'], ['smartphone', 'white', 'nokia'], ['smartphone', 'black', 'oneplus'], ['smartphone', 'red', 'motorola']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['shirt', 'blue', 'tshirt'], ['jeans', 'blue', 'levis'], ['shirt', 'green', 'polo'], ['shorts', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shirt', 'blue', 'reebok']],ruleKey = \"color\",ruleValue = \"blue\") == 5\n assert candidate(items = [['shirt', 'blue', 'nike'], ['pants', 'red', 'adidas'], ['hat', 'blue', 'reebok'], ['jacket', 'green', 'nike'], ['shoes', 'black', 'puma']],ruleKey = \"name\",ruleValue = \"nike\") == 2\n assert candidate(items = [['television', 'black', 'samsung'], ['television', 'silver', 'lg'], ['television', 'gray', 'tcl'], ['television', 'black', 'sony'], ['television', 'red', 'panasonic']],ruleKey = \"type\",ruleValue = \"television\") == 5\n assert candidate(items = [['shirt', 'blue', 'tshirt'], ['jeans', 'blue', 'levis'], ['shirt', 'green', 'polo'], ['shorts', 'blue', 'nike'], ['pants', 'blue', 'adidas']],ruleKey = \"name\",ruleValue = \"nike\") == 1\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'lenovo'], ['phone', 'gold', 'iphone'], ['tv', 'black', 'samsung'], ['monitor', 'silver', 'dell'], ['laptop', 'gray', 'hp'], ['phone', 'black', 'nokia'], ['tablet', 'gold', 'ipad']],ruleKey = \"type\",ruleValue = \"phone\") == 3\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'gold', 'fitbit'], ['laptop', 'gray', 'hp']],ruleKey = \"name\",ruleValue = \"dell\") == 1\n assert candidate(items = [['tv', 'black', 'samsung'], ['tv', 'white', 'lg'], ['tv', 'silver', 'sony'], ['tv', 'black', 'toshiba'], ['tv', 'white', 'vizio']],ruleKey = \"color\",ruleValue = \"white\") == 2\n assert candidate(items = [['toy', 'red', 'car'], ['toy', 'blue', 'doll'], ['toy', 'green', 'car'], ['toy', 'red', 'ball'], ['toy', 'green', 'doll'], ['toy', 'blue', 'ball']],ruleKey = \"name\",ruleValue = \"car\") == 2\n assert candidate(items = [['clothing', 'blue', 'shirt'], ['clothing', 'red', 't-shirt'], ['clothing', 'blue', 'jeans'], ['clothing', 'green', 'pants'], ['clothing', 'blue', 'jacket'], ['clothing', 'yellow', 'shorts'], ['clothing', 'blue', 'hat']],ruleKey = \"color\",ruleValue = \"blue\") == 4\n assert candidate(items = [['chair', 'brown', 'leather'], ['table', 'white', 'wood'], ['lamp', 'black', 'glass'], ['sofa', 'gray', 'cotton'], ['rug', 'blue', 'carpet'], ['cabinet', 'black', 'oak'], ['bed', 'white', 'sheets'], ['mirror', 'silver', 'frame'], ['shelf', 'black', 'metal']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['shirt', 'white', 'nike'], ['pants', 'blue', 'adidas'], ['shoes', 'black', 'puma'], ['hat', 'white', 'reebok'], ['socks', 'blue', 'nike']],ruleKey = \"color\",ruleValue = \"blue\") == 2\n assert candidate(items = [['couch', 'brown', 'sofa'], ['chair', 'black', 'office'], ['table', 'brown', 'dining'], ['lamp', 'black', 'reading'], ['cabinet', 'brown', 'kitchen']],ruleKey = \"color\",ruleValue = \"brown\") == 3\n assert candidate(items = [['keyboard', 'black', 'logitech'], ['keyboard', 'white', 'razer'], ['keyboard', 'blue', 'corsair'], ['keyboard', 'black', 'microsoft'], ['keyboard', 'black', 'filco']],ruleKey = \"type\",ruleValue = \"keyboard\") == 5\n assert candidate(items = [['shirt', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shoes', 'black', 'reebok'], ['hat', 'red', 'nike'], ['jacket', 'blue', 'puma'], ['watch', 'silver', 'rolex'], ['belt', 'brown', 'gucci']],ruleKey = \"name\",ruleValue = \"nike\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['laptop', 'gray', 'hp'], ['desktop', 'black', 'asus'], ['monitor', 'black', 'dell'], ['laptop', 'silver', 'lenovo']],ruleKey = \"type\",ruleValue = \"laptop\") == 3\n assert candidate(items = [['shirt', 'blue', 'tshirt'], ['jeans', 'blue', 'levis'], ['shirt', 'green', 'polo'], ['shorts', 'blue', 'nike'], ['pants', 'blue', 'adidas']],ruleKey = \"color\",ruleValue = \"blue\") == 4\n assert candidate(items = [['camera', 'black', 'canon'], ['smartphone', 'white', 'iphone'], ['tablet', 'gold', 'ipad'], ['smartwatch', 'black', 'applewatch'], ['laptop', 'silver', 'macbook']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['furniture', 'brown', 'table'], ['furniture', 'white', 'sofa'], ['furniture', 'brown', 'chair'], ['furniture', 'black', 'cabinet'], ['furniture', 'white', 'lamp'], ['furniture', 'brown', 'dresser']],ruleKey = \"color\",ruleValue = \"brown\") == 3\n assert candidate(items = [['computer', 'black', 'macbook'], ['smartwatch', 'silver', 'apple'], ['tablet', 'white', 'samsung'], ['laptop', 'blue', 'dell'], ['desktop', 'black', 'asus'], ['computer', 'silver', 'lenovo'], ['smartwatch', 'white', 'fitbit'], ['tablet', 'black', 'xiaomi']],ruleKey = \"color\",ruleValue = \"white\") == 2\n assert candidate(items = [['camera', 'black', 'canon'], ['camera', 'silver', 'nikon'], ['lens', 'black', 'canon'], ['camera', 'white', 'sony'], ['tripod', 'gray', 'benro'], ['camera', 'black', 'fujifilm']],ruleKey = \"brand\",ruleValue = \"canon\") == 2\n assert candidate(items = [['headphones', 'black', 'sony'], ['headphones', 'black', 'apple'], ['headphones', 'black', 'sennheiser'], ['headphones', 'black', 'bose'], ['headphones', 'black', 'jaybird']],ruleKey = \"color\",ruleValue = \"black\") == 5\n assert candidate(items = [['toy', 'red', 'car'], ['toy', 'blue', 'doll'], ['toy', 'red', 'truck'], ['toy', 'yellow', 'balloon'], ['toy', 'blue', 'teddybear'], ['toy', 'red', 'firetruck']],ruleKey = \"type\",ruleValue = \"toy\") == 6\n assert candidate(items = [['camera', 'black', 'nikon'], ['phone', 'black', 'iphone'], ['tablet', 'black', 'ipad'], ['smartwatch', 'black', 'applewatch'], ['laptop', 'black', 'macbook']],ruleKey = \"color\",ruleValue = \"black\") == 5\n assert candidate(items = [['sneakers', 'white', 'nike'], ['tshirt', 'blue', 'adidas'], ['jeans', 'black', 'puma'], ['hat', 'red', 'nike'], ['pants', 'blue', 'reebok']],ruleKey = \"name\",ruleValue = \"nike\") == 2\n assert candidate(items = [['computer', 'black', 'macbook'], ['smartwatch', 'silver', 'apple'], ['tablet', 'white', 'samsung'], ['laptop', 'blue', 'dell'], ['desktop', 'black', 'asus']],ruleKey = \"type\",ruleValue = \"computer\") == 1\n assert candidate(items = [['monitor', 'black', 'asus'], ['monitor', 'white', 'dell'], ['monitor', 'blue', 'benq'], ['monitor', 'silver', 'acer'], ['monitor', 'black', 'lg']],ruleKey = \"type\",ruleValue = \"monitor\") == 5\n assert candidate(items = [['smartphone', 'black', 'samsung'], ['smartphone', 'blue', 'iphone'], ['smartphone', 'black', 'google'], ['smartphone', 'red', 'oneplus'], ['smartphone', 'black', 'zte']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['shirt', 'black', 'nike'], ['jeans', 'blue', 'levis'], ['jacket', 'brown', 'adidas'], ['shoes', 'white', 'nike'], ['hat', 'black', 'nike'], ['socks', 'blue', 'addidas'], ['gloves', 'brown', 'adidas'], ['shorts', 'white', 'levis']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartphone', 'blue', 'huawei'], ['laptop', 'red', 'macbook']],ruleKey = \"type\",ruleValue = \"smartphone\") == 2\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'lenovo'], ['phone', 'gold', 'iphone'], ['phone', 'black', 'samsung'], ['laptop', 'gray', 'hp'], ['tablet', 'silver', 'ipad']],ruleKey = \"type\",ruleValue = \"phone\") == 3\n assert candidate(items = [['laptop', 'black', 'dell'], ['laptop', 'gray', 'hp'], ['desktop', 'black', 'asus'], ['laptop', 'black', 'lenovo'], ['desktop', 'black', 'acer']],ruleKey = \"color\",ruleValue = \"black\") == 4\n assert candidate(items = [['shirt', 'blue', 'tshirt'], ['jeans', 'blue', 'levis'], ['shirt', 'green', 'polo'], ['shorts', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shirt', 'blue', 'reebok'], ['shirt', 'blue', 'puma']],ruleKey = \"name\",ruleValue = \"blue\") == 0\n assert candidate(items = [['tv', 'black', 'samsung'], ['fridge', 'white', 'lg'], ['microwave', 'black', 'whirlpool'], ['stove', 'black', 'bosch']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['phone', 'blue', 'pixel'], ['phone', 'blue', 'galaxy'], ['phone', 'blue', 'nokia'], ['phone', 'blue', 'oneplus'], ['phone', 'blue', 'google'], ['phone', 'blue', 'xiaomi'], ['phone', 'blue', 'htc']],ruleKey = \"name\",ruleValue = \"google\") == 1\n assert candidate(items = [['smartwatch', 'silver', 'apple'], ['smartwatch', 'gold', 'rolex'], ['bracelet', 'silver', 'tissot'], ['pendant', 'gold', 'omega'], ['bracelet', 'silver', 'casio']],ruleKey = \"name\",ruleValue = \"silver\") == 0\n", "comparison": "exact"}, "public_tests": ["[[\"phone\",\"blue\",\"pixel\"],[\"computer\",\"silver\",\"lenovo\"],[\"phone\",\"gold\",\"iphone\"]]\n\"color\"\n\"silver\"", "[[\"phone\",\"blue\",\"pixel\"],[\"computer\",\"silver\",\"phone\"],[\"phone\",\"gold\",\"iphone\"]]\n\"type\"\n\"phone\""], "hints": ["Iterate on each item, and check if each one matches the rule according to the statement."], "metadata": {"canonical_parameter_names": ["items", "ruleKey", "ruleValue"], "leetcode_dataset_entry_point": "Solution().countMatches", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:20+00:00", "tests_total": 108, "tests_dropped": 41, "flags": [], "topic_tags": ["array", "string"]}, "language": "javascript", "interface": {"raw_signature": "var countMatches = function(items, ruleKey, ruleValue) {", "container": null, "callable": "countMatches", "parameters": [{"name": "items", "type": "string[][]"}, {"name": "ruleKey", "type": "string"}, {"name": "ruleValue", "type": "string"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1774, "task_id": "closest-dessert-cost", "difficulty": "Medium", "problem_description": "You would like to make dessert and are preparing to buy the ingredients. You have n ice cream base flavors and m types of toppings to choose from. You must follow these rules when making your dessert:\n\n- There must be exactly one ice cream base.\n- You can add one or more types of topping or have no toppings at all.\n- There are at most two of each type of topping.\n\nYou are given three inputs:\n\n- baseCosts, an integer array of length n, where each baseCosts[i] represents the price of the i^th ice cream base flavor.\n- toppingCosts, an integer array of length m, where each toppingCosts[i] is the price of one of the i^th topping.\n- target, an integer representing your target price for dessert.\n\nYou want to make a dessert with a total cost as close to target as possible.\n\nReturn the closest possible cost of the dessert to target. If there are multiple, return the lower one.\n\nExample 1:\n\nInput: baseCosts = [1,7], toppingCosts = [3,4], target = 10\nOutput: 10\nExplanation: Consider the following combination (all 0-indexed):\n- Choose base 1: cost 7\n- Take 1 of topping 0: cost 1 x 3 = 3\n- Take 0 of topping 1: cost 0 x 4 = 0\nTotal: 7 + 3 + 0 = 10.\n\nExample 2:\n\nInput: baseCosts = [2,3], toppingCosts = [4,5,100], target = 18\nOutput: 17\nExplanation: Consider the following combination (all 0-indexed):\n- Choose base 1: cost 3\n- Take 1 of topping 0: cost 1 x 4 = 4\n- Take 2 of topping 1: cost 2 x 5 = 10\n- Take 0 of topping 2: cost 0 x 100 = 0\nTotal: 3 + 4 + 10 + 0 = 17. You cannot make a dessert with a total cost of 18.\n\nExample 3:\n\nInput: baseCosts = [3,10], toppingCosts = [2,5], target = 9\nOutput: 8\nExplanation: It is possible to make desserts with cost 8 and 10. Return 8 as it is the lower cost.\n\nConstraints:\n\n- n == baseCosts.length\n- m == toppingCosts.length\n- 1 <= n, m <= 10\n- 1 <= baseCosts[i], toppingCosts[i] <= 10^4\n- 1 <= target <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(baseCosts = [10, 20],toppingCosts = [1, 2, 3],target = 15) == 15\n assert candidate(baseCosts = [5, 9],toppingCosts = [2, 3, 7],target = 15) == 15\n assert candidate(baseCosts = [1, 7],toppingCosts = [3, 4],target = 10) == 10\n assert candidate(baseCosts = [10, 20, 30],toppingCosts = [1, 2, 3, 4, 5],target = 25) == 25\n assert candidate(baseCosts = [4, 8],toppingCosts = [1, 3],target = 15) == 15\n assert candidate(baseCosts = [5],toppingCosts = [1, 2, 3],target = 8) == 8\n assert candidate(baseCosts = [4],toppingCosts = [1, 2, 3],target = 8) == 8\n assert candidate(baseCosts = [10, 20],toppingCosts = [5, 15, 25],target = 50) == 50\n assert candidate(baseCosts = [1],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 10) == 10\n assert candidate(baseCosts = [5, 8],toppingCosts = [6, 1, 2],target = 20) == 20\n assert candidate(baseCosts = [10],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 20) == 20\n assert candidate(baseCosts = [2, 3],toppingCosts = [4, 5, 100],target = 18) == 17\n assert candidate(baseCosts = [3, 10],toppingCosts = [2, 5],target = 9) == 8\n assert candidate(baseCosts = [4, 8, 12, 16, 20],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 30) == 30\n assert candidate(baseCosts = [50, 75, 100, 125],toppingCosts = [10, 15, 20, 25, 30],target = 300) == 300\n assert candidate(baseCosts = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],toppingCosts = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1023) == 1023\n assert candidate(baseCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 1500) == 1500\n assert candidate(baseCosts = [1234, 5678, 9101],toppingCosts = [111, 222, 333, 444, 555, 666],target = 10000) == 10007\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000],toppingCosts = [50, 100, 150, 200, 250, 300, 350],target = 10000) == 7800\n assert candidate(baseCosts = [15, 25, 35, 45],toppingCosts = [2, 4, 6, 8, 10],target = 50) == 49\n assert candidate(baseCosts = [100, 200, 300, 400],toppingCosts = [10, 20, 30, 40, 50],target = 500) == 500\n assert candidate(baseCosts = [123, 456, 789],toppingCosts = [987, 654, 321, 654, 321, 987],target = 1000) == 1086\n assert candidate(baseCosts = [10, 20, 30, 40, 50],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 150) == 150\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 7500) == 7500\n assert candidate(baseCosts = [1, 5, 10, 15],toppingCosts = [3, 6, 9, 12],target = 30) == 30\n assert candidate(baseCosts = [7, 14, 21],toppingCosts = [3, 6, 9, 12, 15, 18],target = 30) == 30\n assert candidate(baseCosts = [500, 1000, 1500],toppingCosts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],target = 3000) == 3000\n assert candidate(baseCosts = [1000, 2000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 5000) == 5000\n assert candidate(baseCosts = [8, 16, 24],toppingCosts = [2, 4, 6, 8, 10, 12, 14, 16],target = 35) == 34\n assert candidate(baseCosts = [3, 6, 9, 12, 15],toppingCosts = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1024) == 1024\n assert candidate(baseCosts = [300, 600, 900],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 1200) == 1200\n assert candidate(baseCosts = [1, 2, 3, 4, 5],toppingCosts = [5, 10, 15, 20, 25],target = 50) == 50\n assert candidate(baseCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 50) == 50\n assert candidate(baseCosts = [100, 200, 300],toppingCosts = [50, 75, 100, 125, 150],target = 600) == 600\n assert candidate(baseCosts = [1, 10000],toppingCosts = [5000, 3000, 2000, 1000, 500, 100],target = 9000) == 9001\n assert candidate(baseCosts = [15, 25, 35],toppingCosts = [5, 7, 11, 13, 17],target = 50) == 50\n assert candidate(baseCosts = [100, 150, 200, 250],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 750) == 750\n assert candidate(baseCosts = [999, 1999, 2999],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 5000) == 3109\n assert candidate(baseCosts = [1, 1, 1, 1, 1],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 25) == 25\n assert candidate(baseCosts = [150, 250, 350],toppingCosts = [5, 15, 25, 35, 45, 55],target = 400) == 400\n assert candidate(baseCosts = [2000, 4000, 6000],toppingCosts = [100, 200, 300, 400, 500],target = 7000) == 7000\n assert candidate(baseCosts = [1, 10, 100],toppingCosts = [9, 90, 900, 9000],target = 10000) == 10000\n assert candidate(baseCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 1000) == 1000\n assert candidate(baseCosts = [15, 25, 35, 45],toppingCosts = [1, 2, 3, 4, 5, 6, 7],target = 30) == 30\n assert candidate(baseCosts = [10, 20, 30],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 45) == 45\n assert candidate(baseCosts = [1, 1, 1, 1, 1],toppingCosts = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 100) == 101\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 10000) == 10000\n assert candidate(baseCosts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 100) == 100\n assert candidate(baseCosts = [500, 250],toppingCosts = [100, 200, 300, 400, 500],target = 1000) == 1000\n assert candidate(baseCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 500) == 210\n assert candidate(baseCosts = [100, 200, 300],toppingCosts = [10, 20, 30, 40, 50, 60],target = 500) == 500\n assert candidate(baseCosts = [1000, 2000, 3000],toppingCosts = [500, 100, 250, 125, 75],target = 4500) == 4500\n assert candidate(baseCosts = [123, 456, 789],toppingCosts = [11, 22, 33, 44, 55, 66, 77, 88, 99],target = 1000) == 998\n assert candidate(baseCosts = [5, 10, 15, 20, 25],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 20) == 20\n assert candidate(baseCosts = [9999],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10000) == 10000\n assert candidate(baseCosts = [123, 456, 789],toppingCosts = [987, 654, 321, 123, 456, 789, 100, 200, 300],target = 2000) == 2000\n assert candidate(baseCosts = [500, 501, 502],toppingCosts = [250, 251, 252, 253],target = 1000) == 1000\n assert candidate(baseCosts = [777, 888],toppingCosts = [55, 44, 33, 22, 11, 1, 2, 3, 4, 5],target = 2000) == 1248\n assert candidate(baseCosts = [10, 20, 30, 40, 50],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 25) == 25\n assert candidate(baseCosts = [10, 20, 30, 40, 50],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 50) == 50\n assert candidate(baseCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 10) == 10\n assert candidate(baseCosts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 30) == 30\n assert candidate(baseCosts = [123, 456, 789],toppingCosts = [11, 22, 33, 44, 55],target = 700) == 698\n assert candidate(baseCosts = [100, 200, 300, 400],toppingCosts = [10, 20, 30, 40, 50, 60],target = 750) == 750\n assert candidate(baseCosts = [100, 200],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 500) == 310\n assert candidate(baseCosts = [1000, 1001, 1002, 1003],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10000) == 1113\n assert candidate(baseCosts = [23, 45, 67, 89, 10],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 200) == 199\n assert candidate(baseCosts = [5, 10, 15, 20],toppingCosts = [1, 3, 5, 7, 9, 11, 13],target = 40) == 40\n assert candidate(baseCosts = [100, 200, 300, 400, 500],toppingCosts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 1000) == 1000\n assert candidate(baseCosts = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],toppingCosts = [2, 4, 6, 8, 10],target = 50) == 49\n assert candidate(baseCosts = [100, 200, 300, 400],toppingCosts = [10, 20, 30, 40, 50, 60],target = 1500) == 820\n assert candidate(baseCosts = [100, 200, 300, 400],toppingCosts = [50, 10, 15, 20, 25, 30, 35, 40, 45, 55],target = 1500) == 1050\n assert candidate(baseCosts = [1, 2, 3, 4, 5],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 100) == 101\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],toppingCosts = [500, 1500, 2500, 3500],target = 7500) == 7500\n assert candidate(baseCosts = [2000, 3000, 4000, 5000],toppingCosts = [50, 100, 150, 200, 250],target = 8500) == 6500\n assert candidate(baseCosts = [50, 100, 150, 200, 250, 300],toppingCosts = [5, 10, 15, 20, 25, 30],target = 750) == 510\n assert candidate(baseCosts = [100, 200],toppingCosts = [50, 25, 10, 5, 1],target = 300) == 300\n assert candidate(baseCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 5000) == 5001\n assert candidate(baseCosts = [1000, 2000, 3000],toppingCosts = [500, 1000, 1500, 2000, 2500],target = 6000) == 6000\n assert candidate(baseCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 50) == 50\n assert candidate(baseCosts = [800, 1600, 2400],toppingCosts = [100, 200, 300, 400, 500, 600],target = 3000) == 3000\n assert candidate(baseCosts = [1000, 2000, 3000],toppingCosts = [500, 100, 250, 150, 200],target = 4500) == 4500\n assert candidate(baseCosts = [4, 8, 12, 16, 20],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 45) == 45\n assert candidate(baseCosts = [1, 2, 3, 4, 5],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 500) == 501\n assert candidate(baseCosts = [50, 60, 70, 80, 90],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 150) == 150\n assert candidate(baseCosts = [100, 200, 300],toppingCosts = [50, 75, 100, 125, 150],target = 500) == 500\n assert candidate(baseCosts = [10, 20],toppingCosts = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1000) == 1000\n assert candidate(baseCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 500) == 210\n assert candidate(baseCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],toppingCosts = [9999],target = 10000) == 10000\n assert candidate(baseCosts = [5, 10],toppingCosts = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 15) == 15\n assert candidate(baseCosts = [500, 1000, 1500],toppingCosts = [5, 10, 15, 20, 25, 30, 35, 40],target = 2000) == 1860\n assert candidate(baseCosts = [999, 1000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 4000) == 4000\n", "comparison": "exact"}, "public_tests": ["[1,7]\n[3,4]\n10", "[2,3]\n[4,5,100]\n18", "[3,10]\n[2,5]\n9"], "hints": ["As the constraints are not large, you can brute force and enumerate all the possibilities."], "metadata": {"canonical_parameter_names": ["baseCosts", "toppingCosts", "target"], "leetcode_dataset_entry_point": "Solution().closestCost", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:23+00:00", "tests_total": 99, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "dynamic-programming", "backtracking", "knapsack-problem", "mixed-knapsack"]}, "language": "javascript", "interface": {"raw_signature": "var closestCost = function(baseCosts, toppingCosts, target) {", "container": null, "callable": "closestCost", "parameters": [{"name": "baseCosts", "type": "number[]"}, {"name": "toppingCosts", "type": "number[]"}, {"name": "target", "type": "number"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1775, "task_id": "equal-sum-arrays-with-minimum-number-of-operations", "difficulty": "Medium", "problem_description": "You are given two arrays of integers nums1 and nums2, possibly of different lengths. The values in the arrays are between 1 and 6, inclusive.\n\nIn one operation, you can change any integer's value in any of the arrays to any value between 1 and 6, inclusive.\n\nReturn the minimum number of operations required to make the sum of values in nums1 equal to the sum of values in nums2. Return -1 if it is not possible to make the sum of the two arrays equal.\n\nExample 1:\n\nInput: nums1 = [1,2,3,4,5,6], nums2 = [1,1,2,2,2,2]\nOutput: 3\nExplanation: You can make the sums of nums1 and nums2 equal with 3 operations. All indices are 0-indexed.\n- Change nums2[0] to 6. nums1 = [1,2,3,4,5,6], nums2 = [6,1,2,2,2,2].\n- Change nums1[5] to 1. nums1 = [1,2,3,4,5,1], nums2 = [6,1,2,2,2,2].\n- Change nums1[2] to 2. nums1 = [1,2,2,4,5,1], nums2 = [6,1,2,2,2,2].\n\nExample 2:\n\nInput: nums1 = [1,1,1,1,1,1,1], nums2 = [6]\nOutput: -1\nExplanation: There is no way to decrease the sum of nums1 or to increase the sum of nums2 to make them equal.\n\nExample 3:\n\nInput: nums1 = [6,6], nums2 = [1]\nOutput: 3\nExplanation: You can make the sums of nums1 and nums2 equal with 3 operations. All indices are 0-indexed.\n- Change nums1[0] to 2. nums1 = [2,6], nums2 = [1].\n- Change nums1[1] to 2. nums1 = [2,2], nums2 = [1].\n- Change nums2[0] to 4. nums1 = [2,2], nums2 = [4].\n\nConstraints:\n\n- 1 <= nums1.length, nums2.length <= 10^5\n- 1 <= nums1[i], nums2[i] <= 6\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums1 = [3, 3, 3, 3],nums2 = [2, 2, 2, 2]) == 1\n assert candidate(nums1 = [1, 1],nums2 = [6, 6]) == 2\n assert candidate(nums1 = [6, 6, 6],nums2 = [1, 1]) == 4\n assert candidate(nums1 = [1, 1, 2],nums2 = [6, 6, 6]) == 3\n assert candidate(nums1 = [1, 1],nums2 = [6, 6, 6]) == 4\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums1 = [1, 2],nums2 = [5, 6]) == 2\n assert candidate(nums1 = [6, 6, 6],nums2 = [1, 1, 1]) == 3\n assert candidate(nums1 = [3, 3, 3],nums2 = [3, 3, 3]) == 0\n assert candidate(nums1 = [2, 3, 4],nums2 = [5, 5, 5]) == 2\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1],nums2 = [6]) == -1\n assert candidate(nums1 = [6],nums2 = [1]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [1, 1, 2, 2, 2, 2]) == 3\n assert candidate(nums1 = [3, 3, 3],nums2 = [2, 2, 2]) == 1\n assert candidate(nums1 = [6, 6],nums2 = [1]) == 3\n assert candidate(nums1 = [2, 2, 2],nums2 = [5, 5, 5]) == 3\n assert candidate(nums1 = [3, 3, 3],nums2 = [2, 2, 2, 2]) == 1\n assert candidate(nums1 = [1],nums2 = [6]) == 1\n assert candidate(nums1 = [1, 1, 1],nums2 = [6, 6, 6]) == 3\n assert candidate(nums1 = [3],nums2 = [3]) == 0\n assert candidate(nums1 = [1, 3, 5],nums2 = [2, 4, 6]) == 1\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == 2\n assert candidate(nums1 = [5, 5],nums2 = [1, 1]) == 2\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1]) == 4\n assert candidate(nums1 = [3, 3, 3, 3],nums2 = [1, 6, 1, 6]) == 1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 6\n assert candidate(nums1 = [1, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 2]) == 5\n assert candidate(nums1 = [6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [1, 2, 3, 4, 5, 6]) == 3\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [1, 6, 1, 6, 1, 6],nums2 = [6, 1, 6, 1, 6, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],nums2 = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 1\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5],nums2 = [6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 2]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 58\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [4, 5, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 8\n assert candidate(nums1 = [1, 3, 5, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6]) == 6\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == -1\n assert candidate(nums1 = [2, 3, 4, 5, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 9\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [2, 3, 4, 5, 6]) == 4\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1],nums2 = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6]) == 5\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5]) == 11\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 6\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 5\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 18\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6]) == 6\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 7\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 12\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2],nums2 = [2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3]) == 1\n assert candidate(nums1 = [1, 3, 5, 1, 3, 5, 1, 3, 5],nums2 = [2, 4, 6, 2, 4, 6, 2, 4, 6]) == 2\n assert candidate(nums1 = [1, 6, 1, 6, 1, 6],nums2 = [2, 5, 2, 5, 2, 5]) == 0\n assert candidate(nums1 = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4],nums2 = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 7\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [6, 6, 6, 6, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 10\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 2, 3, 4, 5, 6, 6, 6, 6]) == 3\n assert candidate(nums1 = [2, 3, 4, 5, 6],nums2 = [1, 1, 1, 1]) == 4\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 131\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5]) == 2\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 6, 6, 6],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1],nums2 = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 15\n assert candidate(nums1 = [1, 6, 1, 6, 1, 6, 1, 6, 1, 6],nums2 = [6, 1, 6, 1, 6, 1, 6, 1, 6, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 6]) == 2\n assert candidate(nums1 = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 9\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 30\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 28\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 14\n assert candidate(nums1 = [2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 3, 4, 5, 6]) == 3\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums1 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 11\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 8\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == 5\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6]) == 4\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1],nums2 = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 3\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [3, 3, 3, 3, 3, 3]) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 33\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 21\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3],nums2 = [4, 4, 4, 4, 4, 4, 4]) == 3\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [2, 3, 4, 5, 6, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 15\n assert candidate(nums1 = [4, 4, 4, 4, 4, 4, 4],nums2 = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums1 = [6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(nums1 = [4, 4, 4, 4, 4, 4],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums1 = [6, 4, 2, 6, 4, 2, 6, 4, 2],nums2 = [1, 3, 5, 1, 3, 5, 1, 3, 5]) == 2\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5]) == 3\n assert candidate(nums1 = [1, 3, 5, 1, 3, 5, 1, 3, 5, 1, 3, 5],nums2 = [2, 4, 6, 2, 4, 6, 2, 4, 6, 2, 4, 6]) == 3\n assert candidate(nums1 = [2, 3, 4],nums2 = [1, 5, 6, 6]) == 2\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [6, 6, 6, 6, 6]) == 2\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 6, 6, 6, 6, 6]) == 5\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 15\n assert candidate(nums1 = [1, 3, 5],nums2 = [2, 4, 6]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 7\n assert candidate(nums1 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 20\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 8\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1]) == 5\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6]) == 7\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [4, 4, 5, 5, 6, 6]) == 4\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6]) == -1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 8\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [4, 5, 6, 6, 6, 6, 6]) == 5\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1]) == 6\n", "comparison": "exact"}, "public_tests": ["[1,2,3,4,5,6]\n[1,1,2,2,2,2]", "[1,1,1,1,1,1,1]\n[6]", "[6,6]\n[1]"], "hints": ["Let's note that we want to either decrease the sum of the array with a larger sum or increase the array's sum with the smaller sum.", "You can maintain the largest increase or decrease you can make in a binary search tree and each time get the maximum one."], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:25+00:00", "tests_total": 138, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "greedy", "counting"]}, "language": "javascript", "interface": {"raw_signature": "var minOperations = function(nums1, nums2) {", "container": null, "callable": "minOperations", "parameters": [{"name": "nums1", "type": "number[]"}, {"name": "nums2", "type": "number[]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1776, "task_id": "car-fleet-ii", "difficulty": "Hard", "problem_description": "There are n cars traveling at different speeds in the same direction along a one-lane road. You are given an array cars of length n, where cars[i] = [position_i, speed_i] represents:\n\n- position_i is the distance between the i^th car and the beginning of the road in meters. It is guaranteed that position_i < position_{i+1}.\n- speed_i is the initial speed of the i^th car in meters per second.\n\nFor simplicity, cars can be considered as points moving along the number line. Two cars collide when they occupy the same position. Once a car collides with another car, they unite and form a single car fleet. The cars in the formed fleet will have the same position and the same speed, which is the initial speed of the slowest car in the fleet.\n\nReturn an array answer, where answer[i] is the time, in seconds, at which the i^th car collides with the next car, or -1 if the car does not collide with the next car. Answers within 10^-5 of the actual answers are accepted.\n\nExample 1:\n\nInput: cars = [[1,2],[2,1],[4,3],[7,2]]\nOutput: [1.00000,-1.00000,3.00000,-1.00000]\nExplanation: After exactly one second, the first car will collide with the second car, and form a car fleet with speed 1 m/s. After exactly 3 seconds, the third car will collide with the fourth car, and form a car fleet with speed 2 m/s.\n\nExample 2:\n\nInput: cars = [[3,4],[5,4],[6,3],[9,1]]\nOutput: [2.00000,1.00000,1.50000,-1.00000]\n\nConstraints:\n\n- 1 <= cars.length <= 10^5\n- 1 <= position_i, speed_i <= 10^6\n- position_i < position_{i+1}\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(cars=[[1, 4], [2, 3], [3, 2], [4, 1]]), [1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 5], [3, 2], [5, 1]]), [0.6666666666666666, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]), [-1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[3, 4], [5, 4], [6, 3], [9, 1]]), [2.0, 1.0, 1.5, -1])\n assert answers_match(candidate(cars=[[1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]), [-1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[5, 10], [10, 5], [15, 2], [20, 1]]), [1.0, 1.6666666666666667, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [3, 8], [5, 6], [7, 4], [9, 2]]), [1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]]), [-1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 2], [2, 1], [4, 3], [7, 2]]), [1.0, -1, 3.0, -1])\n assert answers_match(candidate(cars=[[10, 10], [8, 5], [6, 3], [4, 2], [2, 1]]), [-0.8888888888888888, -1.5, -2.0, -2.0, -1])\n assert answers_match(candidate(cars=[[10, 2], [20, 1], [30, 3], [40, 2]]), [10.0, -1, 10.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[5, 10], [15, 8], [20, 7], [25, 6], [30, 5]]), [5.0, 5.0, 5.0, 5.0, -1])\n assert answers_match(candidate(cars=[[10, 5], [20, 4], [30, 3], [40, 2], [50, 1]]), [10.0, 10.0, 10.0, 10.0, -1])\n assert answers_match(candidate(cars=[[10, 5], [15, 3], [20, 2], [25, 1]]), [2.5, 5.0, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]), [1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [3, 6], [5, 5], [7, 4]]), [0.5, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 20], [2, 18], [3, 16], [4, 14], [5, 12], [6, 10], [7, 8], [8, 6], [9, 4], [10, 2]]), [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -1])\n assert answers_match(candidate(cars=[[2, 9], [5, 7], [8, 6], [11, 4], [14, 2], [17, 1]]), [1.5, 1.8, 1.5, 1.5, 3.0, -1])\n assert answers_match(candidate(cars=[[10, 5], [20, 15], [30, 10], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45]]), [-1, 2.0, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10], [100, 1]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.1111111111111112, -1])\n assert answers_match(candidate(cars=[[1, 100], [10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10]]), [0.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[50, 100], [150, 90], [250, 80], [350, 70], [450, 60], [550, 50], [650, 40], [750, 30], [850, 20], [950, 10]]), [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, -1])\n assert answers_match(candidate(cars=[[1, 25], [3, 24], [5, 23], [7, 22], [9, 21], [11, 20], [13, 19], [15, 18], [17, 17], [19, 16], [21, 15]]), [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [10, 9], [19, 8], [28, 7], [37, 6], [46, 5], [55, 4], [64, 3], [73, 2], [82, 1]]), [9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, -1])\n assert answers_match(candidate(cars=[[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11], [11, 10], [12, 9], [13, 8], [14, 7], [15, 6], [16, 5], [17, 4], [18, 3], [19, 2], [20, 1]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [12, 10], [14, 9], [16, 8], [18, 7], [20, 6], [22, 5], [24, 4], [26, 3], [28, 2], [30, 1]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]]), [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, -1])\n assert answers_match(candidate(cars=[[1, 50], [10, 45], [20, 40], [30, 35], [40, 30], [50, 25], [60, 20], [70, 15], [80, 10], [90, 5]]), [1.8, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 5], [2, 10], [3, 15], [4, 20], [5, 25], [6, 30], [7, 35], [8, 40], [9, 45], [10, 50]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 10], [4, 8], [7, 6], [10, 4], [13, 2], [16, 1]]), [1.5, 1.5, 1.5, 1.5, 3.0, -1])\n assert answers_match(candidate(cars=[[1, 8], [3, 7], [5, 6], [7, 5], [9, 4], [11, 3], [13, 2], [15, 1]]), [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 30], [4, 20], [7, 15], [10, 10], [13, 8], [16, 6], [19, 4], [22, 2], [25, 1]]), [0.3, 0.6, 0.6, 1.5, 1.5, 1.5, 1.5, 3.0, -1])\n assert answers_match(candidate(cars=[[1, 100], [10, 95], [20, 90], [30, 85], [40, 80], [50, 75], [60, 70], [70, 65], [80, 60], [90, 55]]), [1.8, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 15], [2, 25], [3, 35], [4, 45], [5, 55], [6, 65], [7, 75], [8, 85], [9, 95], [10, 105]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 5], [4, 4], [7, 3], [10, 2], [13, 1]]), [3.0, 3.0, 3.0, 3.0, -1])\n assert answers_match(candidate(cars=[[1, 100], [20, 50], [30, 30], [40, 20], [50, 10], [60, 1]]), [0.38, 0.5, 1.0, 1.0, 1.1111111111111112, -1])\n assert answers_match(candidate(cars=[[1, 15], [2, 10], [4, 5], [6, 4], [8, 3], [10, 2], [12, 1]]), [0.2, 0.4, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 3], [2, 2], [3, 1], [4, 4], [5, 5], [6, 6]]), [1.0, 1.0, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 200], [11, 180], [21, 160], [31, 140], [41, 120], [51, 100], [61, 80], [71, 60], [81, 40], [91, 20]]), [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -1])\n assert answers_match(candidate(cars=[[1, 5], [3, 4], [5, 3], [7, 2], [9, 1], [11, 10], [13, 9], [15, 8], [17, 7], [19, 6]]), [2.0, 2.0, 2.0, 2.0, -1, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 20], [4, 18], [7, 16], [10, 14], [13, 12], [16, 10], [19, 8], [22, 6], [25, 4], [28, 2], [31, 1]]), [1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 3.0, -1])\n assert answers_match(candidate(cars=[[1, 100000], [2, 99000], [3, 98000], [4, 97000], [5, 96000], [6, 95000], [7, 94000], [8, 93000], [9, 92000], [10, 91000]]), [0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, -1])\n assert answers_match(candidate(cars=[[1, 100], [5, 80], [10, 60], [15, 40], [20, 20], [25, 10]]), [0.2, 0.25, 0.25, 0.25, 0.5, -1])\n assert answers_match(candidate(cars=[[1, 30], [2, 25], [3, 20], [5, 15], [8, 10], [13, 5], [20, 2], [28, 1]]), [0.2, 0.2, 0.4, 0.6, 1.0, 2.3333333333333335, 8.0, -1])\n assert answers_match(candidate(cars=[[1, 12], [3, 10], [5, 8], [7, 6], [9, 4], [11, 2]]), [1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 50], [2, 49], [3, 48], [4, 47], [5, 46], [6, 45], [7, 44], [8, 43], [9, 42], [10, 41]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 5], [6, 10], [11, 5], [16, 10], [21, 5], [26, 10], [31, 5], [36, 10], [41, 5], [46, 10]]), [-1, 1.0, -1, 1.0, -1, 1.0, -1, 1.0, -1, -1])\n assert answers_match(candidate(cars=[[1, 200], [2, 190], [3, 180], [4, 170], [5, 160], [6, 150], [7, 140], [8, 130], [9, 120], [10, 110]]), [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, -1])\n assert answers_match(candidate(cars=[[1, 6], [3, 5], [5, 4], [7, 3], [9, 2], [11, 1], [13, 5], [15, 4], [17, 3], [19, 2], [21, 1]]), [2.0, 2.0, 2.0, 2.0, 2.0, -1, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 15], [5, 14], [10, 13], [15, 12], [20, 11], [25, 10], [30, 9], [35, 8], [40, 7], [45, 6], [50, 5], [55, 4], [60, 3], [65, 2], [70, 1]]), [4.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [5, 10], [10, 10], [15, 10], [20, 10], [25, 10], [30, 10], [35, 10], [40, 10], [45, 10]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 3], [5, 2], [10, 1], [15, 4], [20, 3], [25, 2], [30, 1]]), [4.0, 5.0, -1, 5.0, 5.0, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [2, 9], [5, 8], [8, 7], [13, 6], [18, 5], [24, 4], [30, 3], [36, 2], [42, 1]]), [1.0, 3.0, 3.0, 5.0, 5.0, 6.0, 6.0, 6.0, 6.0, -1])\n assert answers_match(candidate(cars=[[1, 2], [2, 3], [3, 5], [4, 8], [5, 13], [6, 21], [7, 34], [8, 55], [9, 89], [10, 144]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 2], [3, 5], [5, 10], [7, 3], [9, 8], [11, 6], [13, 7], [15, 4]]), [-1, 2.0, 0.2857142857142857, -1, 1.0, 2.0, 0.6666666666666666, -1])\n assert answers_match(candidate(cars=[[3, 12], [6, 10], [9, 8], [12, 6], [15, 4], [18, 2], [21, 1]]), [1.5, 1.5, 1.5, 1.5, 1.5, 3.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [4, 9], [10, 8], [15, 7], [20, 6], [25, 5], [30, 4], [35, 3], [40, 2], [45, 1]]), [3.0, 5.125, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 20], [4, 18], [10, 16], [15, 14], [20, 12], [25, 10], [30, 8], [35, 6], [40, 4], [45, 2]]), [1.5, 2.5625, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, -1])\n assert answers_match(candidate(cars=[[1, 1], [10, 2], [20, 3], [30, 4], [40, 5], [50, 6], [60, 7], [70, 8], [80, 9], [90, 10]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 50], [5, 40], [10, 30], [16, 20], [23, 10], [31, 5], [40, 3], [50, 1]]), [0.4, 0.5, 0.6, 0.7, 1.6, 4.5, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600], [6, 500], [7, 400], [8, 300], [9, 200], [10, 100]]), [0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, -1])\n assert answers_match(candidate(cars=[[1, 20], [2, 18], [3, 16], [5, 14], [8, 12], [13, 10], [20, 8], [28, 6], [37, 4], [46, 2]]), [0.5, 0.5, 1.0, 1.5, 2.5, 3.5, 4.0, 4.5, 4.5, -1])\n assert answers_match(candidate(cars=[[1, 10], [2, 20], [3, 15], [4, 25], [5, 20], [6, 30], [7, 25], [8, 35], [9, 30], [10, 40]]), [-1, 0.2, -1, 0.2, -1, 0.2, -1, 0.2, -1, -1])\n assert answers_match(candidate(cars=[[10, 10], [20, 9], [30, 8], [40, 7], [50, 6], [60, 5], [70, 4], [80, 3], [90, 2], [100, 1]]), [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [11, 9], [21, 8], [31, 7], [41, 6], [51, 5], [61, 4], [71, 3], [81, 2], [91, 1]]), [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [3, 10], [5, 10], [7, 10], [9, 10], [11, 10], [13, 10], [15, 10], [17, 10], [19, 10], [21, 10]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 30], [2, 29], [3, 28], [4, 27], [5, 26], [6, 25], [7, 24], [8, 23], [9, 22], [10, 21]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[10, 10], [25, 9], [40, 8], [55, 7], [70, 6], [85, 5], [100, 4], [115, 3], [130, 2], [145, 1]]), [15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, -1])\n assert answers_match(candidate(cars=[[1, 2], [5, 4], [9, 6], [13, 8], [17, 10], [21, 12], [25, 14], [29, 16], [33, 18], [37, 20]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 1], [100000, 100000], [200000, 99999], [300000, 99998], [400000, 99997], [500000, 99996]]), [-1, 100000.0, 100000.0, 100000.0, 100000.0, -1])\n assert answers_match(candidate(cars=[[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 50], [3, 45], [6, 40], [10, 35], [15, 30], [21, 25], [28, 20], [36, 15], [45, 10], [55, 5]]), [0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 100], [5, 90], [10, 80], [15, 70], [20, 60], [25, 50], [30, 40], [35, 30], [40, 20], [45, 10]]), [0.4, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -1])\n assert answers_match(candidate(cars=[[1, 10], [11, 9.99999], [21, 9.99998], [31, 9.99997], [41, 9.99996], [51, 9.99995], [61, 9.99994], [71, 9.99993], [81, 9.99992], [91, 9.99991]]), [999999.9999786458, 999999.9999490399, 999999.999860222, 1000000.0000023306, 999999.9999934488, 999999.9999786458, 999999.9999490399, 999999.999860222, 1000000.0000378577, -1])\n assert answers_match(candidate(cars=[[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86], [16, 85], [17, 84], [18, 83], [19, 82], [20, 81]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 15], [5, 10], [9, 7], [13, 4], [17, 2], [21, 1], [25, 3], [29, 6], [33, 9], [37, 12]]), [0.8, 1.3333333333333333, 1.3333333333333333, 2.0, 4.0, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 100], [20, 90], [30, 80], [40, 70], [50, 60], [60, 50], [70, 40], [80, 30], [90, 20], [100, 10]]), [1.1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[10, 5], [20, 5], [30, 5], [40, 5], [50, 5], [60, 5], [70, 5], [80, 5], [90, 5], [100, 5]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 150], [4, 130], [7, 110], [10, 90], [13, 70], [16, 50], [19, 30], [22, 10]]), [0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, -1])\n assert answers_match(candidate(cars=[[1, 10], [3, 9], [6, 8], [10, 7], [15, 6], [21, 5], [28, 4], [36, 3], [45, 2], [55, 1]]), [2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, -1])\n assert answers_match(candidate(cars=[[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86], [16, 85], [17, 84], [18, 83], [19, 82], [20, 81], [21, 80], [22, 79], [23, 78], [24, 77], [25, 76], [26, 75], [27, 74], [28, 73], [29, 72], [30, 71]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 30], [4, 28], [7, 26], [10, 24], [13, 22], [16, 20], [19, 18], [22, 16], [25, 14], [28, 12], [31, 10], [34, 8], [37, 6], [40, 4], [43, 2]]), [1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, -1])\n assert answers_match(candidate(cars=[[1, 5], [5, 10], [9, 5], [13, 10], [17, 5], [21, 10], [25, 5], [29, 10], [33, 5], [37, 10]]), [-1, 0.8, -1, 0.8, -1, 0.8, -1, 0.8, -1, -1])\n assert answers_match(candidate(cars=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 10], [2, 9.5], [3, 9], [4, 8.5], [5, 8], [6, 7.5], [7, 7], [8, 6.5], [9, 6], [10, 5.5], [11, 5]]), [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 15], [4, 12], [7, 9], [10, 6], [13, 3], [16, 2], [19, 1]]), [1.0, 1.0, 1.0, 1.0, 3.0, 3.0, -1])\n", "comparison": "float"}, "public_tests": ["[[1,2],[2,1],[4,3],[7,2]]", "[[3,4],[5,4],[6,3],[9,1]]"], "hints": ["We can simply ignore the merging of any car fleet, simply assume they cross each other. Now the aim is to find the first car to the right, which intersects with the current car before any other.", "Assume we have already considered all cars to the right already, now the current car is to be considered. Let’s ignore all cars with speeds higher than the current car since the current car cannot intersect with those ones. Now, all cars to the right having speed strictly less than current car are to be considered. Now, for two cars c1 and c2 with positions p1 and p2 (p1 < p2) and speed s1 and s2 (s1 > s2), if c1 and c2 intersect before the current car and c2, then c1 can never be the first car of intersection for any car to the left of current car including current car. So we can remove that car from our consideration.", "We can see that we can maintain candidate cars in this way using a stack, removing cars with speed greater than or equal to current car, and then removing cars which can never be first point of intersection. The first car after this process (if any) would be first point of intersection."], "metadata": {"canonical_parameter_names": ["cars"], "leetcode_dataset_entry_point": "Solution().getCollisionTimes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:28+00:00", "tests_total": 95, "tests_dropped": 4, "flags": ["decimal_answer"], "topic_tags": ["array", "math", "stack", "heap-priority-queue", "monotonic-stack"]}, "language": "javascript", "interface": {"raw_signature": "var getCollisionTimes = function(cars) {", "container": null, "callable": "getCollisionTimes", "parameters": [{"name": "cars", "type": "number[][]"}], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1776, "task_id": "car-fleet-ii", "difficulty": "Hard", "problem_description": "There are n cars traveling at different speeds in the same direction along a one-lane road. You are given an array cars of length n, where cars[i] = [position_i, speed_i] represents:\n\n- position_i is the distance between the i^th car and the beginning of the road in meters. It is guaranteed that position_i < position_{i+1}.\n- speed_i is the initial speed of the i^th car in meters per second.\n\nFor simplicity, cars can be considered as points moving along the number line. Two cars collide when they occupy the same position. Once a car collides with another car, they unite and form a single car fleet. The cars in the formed fleet will have the same position and the same speed, which is the initial speed of the slowest car in the fleet.\n\nReturn an array answer, where answer[i] is the time, in seconds, at which the i^th car collides with the next car, or -1 if the car does not collide with the next car. Answers within 10^-5 of the actual answers are accepted.\n\nExample 1:\n\nInput: cars = [[1,2],[2,1],[4,3],[7,2]]\nOutput: [1.00000,-1.00000,3.00000,-1.00000]\nExplanation: After exactly one second, the first car will collide with the second car, and form a car fleet with speed 1 m/s. After exactly 3 seconds, the third car will collide with the fourth car, and form a car fleet with speed 2 m/s.\n\nExample 2:\n\nInput: cars = [[3,4],[5,4],[6,3],[9,1]]\nOutput: [2.00000,1.00000,1.50000,-1.00000]\n\nConstraints:\n\n- 1 <= cars.length <= 10^5\n- 1 <= position_i, speed_i <= 10^6\n- position_i < position_{i+1}\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_match(r, e) for r, e in zip(result, expected))\n numbers = (int, float)\n if isinstance(result, numbers) and isinstance(expected, numbers) and not isinstance(result, bool):\n return math.isclose(result, expected, rel_tol=1e-5, abs_tol=1e-5)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(cars=[[1, 4], [2, 3], [3, 2], [4, 1]]), [1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 5], [3, 2], [5, 1]]), [0.6666666666666666, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]), [-1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[3, 4], [5, 4], [6, 3], [9, 1]]), [2.0, 1.0, 1.5, -1])\n assert answers_match(candidate(cars=[[1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]), [-1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[5, 10], [10, 5], [15, 2], [20, 1]]), [1.0, 1.6666666666666667, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [3, 8], [5, 6], [7, 4], [9, 2]]), [1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]]), [-1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 2], [2, 1], [4, 3], [7, 2]]), [1.0, -1, 3.0, -1])\n assert answers_match(candidate(cars=[[10, 10], [8, 5], [6, 3], [4, 2], [2, 1]]), [-0.8888888888888888, -1.5, -2.0, -2.0, -1])\n assert answers_match(candidate(cars=[[10, 2], [20, 1], [30, 3], [40, 2]]), [10.0, -1, 10.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[5, 10], [15, 8], [20, 7], [25, 6], [30, 5]]), [5.0, 5.0, 5.0, 5.0, -1])\n assert answers_match(candidate(cars=[[10, 5], [20, 4], [30, 3], [40, 2], [50, 1]]), [10.0, 10.0, 10.0, 10.0, -1])\n assert answers_match(candidate(cars=[[10, 5], [15, 3], [20, 2], [25, 1]]), [2.5, 5.0, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]), [1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [3, 6], [5, 5], [7, 4]]), [0.5, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 20], [2, 18], [3, 16], [4, 14], [5, 12], [6, 10], [7, 8], [8, 6], [9, 4], [10, 2]]), [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -1])\n assert answers_match(candidate(cars=[[2, 9], [5, 7], [8, 6], [11, 4], [14, 2], [17, 1]]), [1.5, 1.8, 1.5, 1.5, 3.0, -1])\n assert answers_match(candidate(cars=[[10, 5], [20, 15], [30, 10], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45]]), [-1, 2.0, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10], [100, 1]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.1111111111111112, -1])\n assert answers_match(candidate(cars=[[1, 100], [10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10]]), [0.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[50, 100], [150, 90], [250, 80], [350, 70], [450, 60], [550, 50], [650, 40], [750, 30], [850, 20], [950, 10]]), [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, -1])\n assert answers_match(candidate(cars=[[1, 25], [3, 24], [5, 23], [7, 22], [9, 21], [11, 20], [13, 19], [15, 18], [17, 17], [19, 16], [21, 15]]), [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [10, 9], [19, 8], [28, 7], [37, 6], [46, 5], [55, 4], [64, 3], [73, 2], [82, 1]]), [9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, -1])\n assert answers_match(candidate(cars=[[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11], [11, 10], [12, 9], [13, 8], [14, 7], [15, 6], [16, 5], [17, 4], [18, 3], [19, 2], [20, 1]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [12, 10], [14, 9], [16, 8], [18, 7], [20, 6], [22, 5], [24, 4], [26, 3], [28, 2], [30, 1]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]]), [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, -1])\n assert answers_match(candidate(cars=[[1, 50], [10, 45], [20, 40], [30, 35], [40, 30], [50, 25], [60, 20], [70, 15], [80, 10], [90, 5]]), [1.8, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 5], [2, 10], [3, 15], [4, 20], [5, 25], [6, 30], [7, 35], [8, 40], [9, 45], [10, 50]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 10], [4, 8], [7, 6], [10, 4], [13, 2], [16, 1]]), [1.5, 1.5, 1.5, 1.5, 3.0, -1])\n assert answers_match(candidate(cars=[[1, 8], [3, 7], [5, 6], [7, 5], [9, 4], [11, 3], [13, 2], [15, 1]]), [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 30], [4, 20], [7, 15], [10, 10], [13, 8], [16, 6], [19, 4], [22, 2], [25, 1]]), [0.3, 0.6, 0.6, 1.5, 1.5, 1.5, 1.5, 3.0, -1])\n assert answers_match(candidate(cars=[[1, 100], [10, 95], [20, 90], [30, 85], [40, 80], [50, 75], [60, 70], [70, 65], [80, 60], [90, 55]]), [1.8, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 15], [2, 25], [3, 35], [4, 45], [5, 55], [6, 65], [7, 75], [8, 85], [9, 95], [10, 105]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 5], [4, 4], [7, 3], [10, 2], [13, 1]]), [3.0, 3.0, 3.0, 3.0, -1])\n assert answers_match(candidate(cars=[[1, 100], [20, 50], [30, 30], [40, 20], [50, 10], [60, 1]]), [0.38, 0.5, 1.0, 1.0, 1.1111111111111112, -1])\n assert answers_match(candidate(cars=[[1, 15], [2, 10], [4, 5], [6, 4], [8, 3], [10, 2], [12, 1]]), [0.2, 0.4, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 3], [2, 2], [3, 1], [4, 4], [5, 5], [6, 6]]), [1.0, 1.0, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 200], [11, 180], [21, 160], [31, 140], [41, 120], [51, 100], [61, 80], [71, 60], [81, 40], [91, 20]]), [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -1])\n assert answers_match(candidate(cars=[[1, 5], [3, 4], [5, 3], [7, 2], [9, 1], [11, 10], [13, 9], [15, 8], [17, 7], [19, 6]]), [2.0, 2.0, 2.0, 2.0, -1, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 20], [4, 18], [7, 16], [10, 14], [13, 12], [16, 10], [19, 8], [22, 6], [25, 4], [28, 2], [31, 1]]), [1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 3.0, -1])\n assert answers_match(candidate(cars=[[1, 100000], [2, 99000], [3, 98000], [4, 97000], [5, 96000], [6, 95000], [7, 94000], [8, 93000], [9, 92000], [10, 91000]]), [0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, -1])\n assert answers_match(candidate(cars=[[1, 100], [5, 80], [10, 60], [15, 40], [20, 20], [25, 10]]), [0.2, 0.25, 0.25, 0.25, 0.5, -1])\n assert answers_match(candidate(cars=[[1, 30], [2, 25], [3, 20], [5, 15], [8, 10], [13, 5], [20, 2], [28, 1]]), [0.2, 0.2, 0.4, 0.6, 1.0, 2.3333333333333335, 8.0, -1])\n assert answers_match(candidate(cars=[[1, 12], [3, 10], [5, 8], [7, 6], [9, 4], [11, 2]]), [1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 50], [2, 49], [3, 48], [4, 47], [5, 46], [6, 45], [7, 44], [8, 43], [9, 42], [10, 41]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 5], [6, 10], [11, 5], [16, 10], [21, 5], [26, 10], [31, 5], [36, 10], [41, 5], [46, 10]]), [-1, 1.0, -1, 1.0, -1, 1.0, -1, 1.0, -1, -1])\n assert answers_match(candidate(cars=[[1, 200], [2, 190], [3, 180], [4, 170], [5, 160], [6, 150], [7, 140], [8, 130], [9, 120], [10, 110]]), [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, -1])\n assert answers_match(candidate(cars=[[1, 6], [3, 5], [5, 4], [7, 3], [9, 2], [11, 1], [13, 5], [15, 4], [17, 3], [19, 2], [21, 1]]), [2.0, 2.0, 2.0, 2.0, 2.0, -1, 2.0, 2.0, 2.0, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 15], [5, 14], [10, 13], [15, 12], [20, 11], [25, 10], [30, 9], [35, 8], [40, 7], [45, 6], [50, 5], [55, 4], [60, 3], [65, 2], [70, 1]]), [4.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [5, 10], [10, 10], [15, 10], [20, 10], [25, 10], [30, 10], [35, 10], [40, 10], [45, 10]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 3], [5, 2], [10, 1], [15, 4], [20, 3], [25, 2], [30, 1]]), [4.0, 5.0, -1, 5.0, 5.0, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [2, 9], [5, 8], [8, 7], [13, 6], [18, 5], [24, 4], [30, 3], [36, 2], [42, 1]]), [1.0, 3.0, 3.0, 5.0, 5.0, 6.0, 6.0, 6.0, 6.0, -1])\n assert answers_match(candidate(cars=[[1, 2], [2, 3], [3, 5], [4, 8], [5, 13], [6, 21], [7, 34], [8, 55], [9, 89], [10, 144]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 2], [3, 5], [5, 10], [7, 3], [9, 8], [11, 6], [13, 7], [15, 4]]), [-1, 2.0, 0.2857142857142857, -1, 1.0, 2.0, 0.6666666666666666, -1])\n assert answers_match(candidate(cars=[[3, 12], [6, 10], [9, 8], [12, 6], [15, 4], [18, 2], [21, 1]]), [1.5, 1.5, 1.5, 1.5, 1.5, 3.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [4, 9], [10, 8], [15, 7], [20, 6], [25, 5], [30, 4], [35, 3], [40, 2], [45, 1]]), [3.0, 5.125, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 20], [4, 18], [10, 16], [15, 14], [20, 12], [25, 10], [30, 8], [35, 6], [40, 4], [45, 2]]), [1.5, 2.5625, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, -1])\n assert answers_match(candidate(cars=[[1, 1], [10, 2], [20, 3], [30, 4], [40, 5], [50, 6], [60, 7], [70, 8], [80, 9], [90, 10]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 50], [5, 40], [10, 30], [16, 20], [23, 10], [31, 5], [40, 3], [50, 1]]), [0.4, 0.5, 0.6, 0.7, 1.6, 4.5, 5.0, -1])\n assert answers_match(candidate(cars=[[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600], [6, 500], [7, 400], [8, 300], [9, 200], [10, 100]]), [0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, -1])\n assert answers_match(candidate(cars=[[1, 20], [2, 18], [3, 16], [5, 14], [8, 12], [13, 10], [20, 8], [28, 6], [37, 4], [46, 2]]), [0.5, 0.5, 1.0, 1.5, 2.5, 3.5, 4.0, 4.5, 4.5, -1])\n assert answers_match(candidate(cars=[[1, 10], [2, 20], [3, 15], [4, 25], [5, 20], [6, 30], [7, 25], [8, 35], [9, 30], [10, 40]]), [-1, 0.2, -1, 0.2, -1, 0.2, -1, 0.2, -1, -1])\n assert answers_match(candidate(cars=[[10, 10], [20, 9], [30, 8], [40, 7], [50, 6], [60, 5], [70, 4], [80, 3], [90, 2], [100, 1]]), [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [11, 9], [21, 8], [31, 7], [41, 6], [51, 5], [61, 4], [71, 3], [81, 2], [91, 1]]), [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, -1])\n assert answers_match(candidate(cars=[[1, 10], [3, 10], [5, 10], [7, 10], [9, 10], [11, 10], [13, 10], [15, 10], [17, 10], [19, 10], [21, 10]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 30], [2, 29], [3, 28], [4, 27], [5, 26], [6, 25], [7, 24], [8, 23], [9, 22], [10, 21]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[10, 10], [25, 9], [40, 8], [55, 7], [70, 6], [85, 5], [100, 4], [115, 3], [130, 2], [145, 1]]), [15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, -1])\n assert answers_match(candidate(cars=[[1, 2], [5, 4], [9, 6], [13, 8], [17, 10], [21, 12], [25, 14], [29, 16], [33, 18], [37, 20]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 1], [100000, 100000], [200000, 99999], [300000, 99998], [400000, 99997], [500000, 99996]]), [-1, 100000.0, 100000.0, 100000.0, 100000.0, -1])\n assert answers_match(candidate(cars=[[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 50], [3, 45], [6, 40], [10, 35], [15, 30], [21, 25], [28, 20], [36, 15], [45, 10], [55, 5]]), [0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, -1])\n assert answers_match(candidate(cars=[[1, 100], [5, 90], [10, 80], [15, 70], [20, 60], [25, 50], [30, 40], [35, 30], [40, 20], [45, 10]]), [0.4, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -1])\n assert answers_match(candidate(cars=[[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86], [16, 85], [17, 84], [18, 83], [19, 82], [20, 81]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 15], [5, 10], [9, 7], [13, 4], [17, 2], [21, 1], [25, 3], [29, 6], [33, 9], [37, 12]]), [0.8, 1.3333333333333333, 1.3333333333333333, 2.0, 4.0, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 100], [20, 90], [30, 80], [40, 70], [50, 60], [60, 50], [70, 40], [80, 30], [90, 20], [100, 10]]), [1.1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[10, 5], [20, 5], [30, 5], [40, 5], [50, 5], [60, 5], [70, 5], [80, 5], [90, 5], [100, 5]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 150], [4, 130], [7, 110], [10, 90], [13, 70], [16, 50], [19, 30], [22, 10]]), [0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, -1])\n assert answers_match(candidate(cars=[[1, 10], [3, 9], [6, 8], [10, 7], [15, 6], [21, 5], [28, 4], [36, 3], [45, 2], [55, 1]]), [2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, -1])\n assert answers_match(candidate(cars=[[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86], [16, 85], [17, 84], [18, 83], [19, 82], [20, 81], [21, 80], [22, 79], [23, 78], [24, 77], [25, 76], [26, 75], [27, 74], [28, 73], [29, 72], [30, 71]]), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1])\n assert answers_match(candidate(cars=[[1, 30], [4, 28], [7, 26], [10, 24], [13, 22], [16, 20], [19, 18], [22, 16], [25, 14], [28, 12], [31, 10], [34, 8], [37, 6], [40, 4], [43, 2]]), [1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, -1])\n assert answers_match(candidate(cars=[[1, 5], [5, 10], [9, 5], [13, 10], [17, 5], [21, 10], [25, 5], [29, 10], [33, 5], [37, 10]]), [-1, 0.8, -1, 0.8, -1, 0.8, -1, 0.8, -1, -1])\n assert answers_match(candidate(cars=[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]), [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\n assert answers_match(candidate(cars=[[1, 15], [4, 12], [7, 9], [10, 6], [13, 3], [16, 2], [19, 1]]), [1.0, 1.0, 1.0, 1.0, 3.0, 3.0, -1])\n", "comparison": "float"}, "public_tests": ["[[1,2],[2,1],[4,3],[7,2]]", "[[3,4],[5,4],[6,3],[9,1]]"], "hints": ["We can simply ignore the merging of any car fleet, simply assume they cross each other. Now the aim is to find the first car to the right, which intersects with the current car before any other.", "Assume we have already considered all cars to the right already, now the current car is to be considered. Let’s ignore all cars with speeds higher than the current car since the current car cannot intersect with those ones. Now, all cars to the right having speed strictly less than current car are to be considered. Now, for two cars c1 and c2 with positions p1 and p2 (p1 < p2) and speed s1 and s2 (s1 > s2), if c1 and c2 intersect before the current car and c2, then c1 can never be the first car of intersection for any car to the left of current car including current car. So we can remove that car from our consideration.", "We can see that we can maintain candidate cars in this way using a stack, removing cars with speed greater than or equal to current car, and then removing cars which can never be first point of intersection. The first car after this process (if any) would be first point of intersection."], "metadata": {"canonical_parameter_names": ["cars"], "leetcode_dataset_entry_point": "Solution().getCollisionTimes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:28+00:00", "tests_total": 95, "tests_dropped": 6, "flags": ["decimal_answer"], "topic_tags": ["array", "math", "stack", "heap-priority-queue", "monotonic-stack"]}, "language": "javascript", "interface": {"raw_signature": "var getCollisionTimes = function(cars) {", "container": null, "callable": "getCollisionTimes", "parameters": [{"name": "cars", "type": "number[][]"}], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1779, "task_id": "find-nearest-point-that-has-the-same-x-or-y-coordinate", "difficulty": "Easy", "problem_description": "You are given two integers, x and y, which represent your current location on a Cartesian grid: (x, y). You are also given an array points where each points[i] = [a_i, b_i] represents that a point exists at (a_i, b_i). A point is valid if it shares the same x-coordinate or the same y-coordinate as your location.\n\nReturn the index (0-indexed) of the valid point with the smallest Manhattan distance from your current location. If there are multiple, return the valid point with the smallest index. If there are no valid points, return -1.\n\nThe Manhattan distance between two points (x_1, y_1) and (x_2, y_2) is abs(x_1 - x_2) + abs(y_1 - y_2).\n\nExample 1:\n\nInput: x = 3, y = 4, points = [[1,2],[3,1],[2,4],[2,3],[4,4]]\nOutput: 2\nExplanation: Of all the points, only [3,1], [2,4] and [4,4] are valid. Of the valid points, [2,4] and [4,4] have the smallest Manhattan distance from your current location, with a distance of 1. [2,4] has the smallest index, so return 2.\n\nExample 2:\n\nInput: x = 3, y = 4, points = [[3,4]]\nOutput: 0\nExplanation: The answer is allowed to be on the same location as your current location.\n\nExample 3:\n\nInput: x = 3, y = 4, points = [[2,3]]\nOutput: -1\nExplanation: There are no valid points.\n\nConstraints:\n\n- 1 <= points.length <= 10^4\n- points[i].length == 2\n- 1 <= x, y, a_i, b_i <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(x = 3,y = 4,points = [[3, 4]]) == 0\n assert candidate(x = 5,y = 5,points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4]]) == 3\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4]]) == -1\n assert candidate(x = 3,y = 4,points = [[2, 3]]) == -1\n assert candidate(x = 1,y = 1,points = [[1, 1], [1, 2], [1, 3], [2, 1], [3, 1]]) == 0\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == -1\n assert candidate(x = 1,y = 1,points = [[1, 1], [1, 2], [2, 1], [2, 2]]) == 0\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5]]) == -1\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 9\n assert candidate(x = 100,y = 100,points = [[50, 100], [100, 50], [150, 100], [100, 150]]) == 0\n assert candidate(x = 5,y = 5,points = [[1, 1], [5, 5], [3, 3], [4, 4]]) == 1\n assert candidate(x = 5,y = 5,points = [[5, 5], [5, 6], [6, 5], [6, 6]]) == 0\n assert candidate(x = 1,y = 10,points = [[1, 1], [1, 2], [1, 3], [1, 4]]) == 3\n assert candidate(x = 5,y = 5,points = [[1, 5], [5, 1], [5, 9], [9, 5], [5, 5]]) == 4\n assert candidate(x = 5,y = 5,points = [[5, 1], [5, 2], [5, 3], [5, 4], [1, 5], [2, 5], [3, 5], [4, 5]]) == 3\n assert candidate(x = 5,y = 5,points = [[10, 10], [5, 5], [1, 1]]) == 1\n assert candidate(x = 1,y = 1,points = [[1, 2], [1, 3], [1, 4], [2, 1], [3, 1]]) == 0\n assert candidate(x = 5,y = 5,points = [[5, 5], [6, 6], [7, 7]]) == 0\n assert candidate(x = 10,y = 10,points = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == -1\n assert candidate(x = 2,y = 3,points = [[2, 3], [1, 1], [3, 3], [4, 4]]) == 0\n assert candidate(x = 10,y = 1,points = [[1, 1], [2, 1], [3, 1], [4, 1]]) == 3\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [4, 4]]) == -1\n assert candidate(x = 3,y = 4,points = [[1, 2], [3, 1], [2, 4], [2, 3], [4, 4]]) == 2\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [10, 10]]) == 3\n assert candidate(x = 5,y = 5,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 4\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 1], [1, 1], [1, 1], [1, 1]]) == 0\n assert candidate(x = 7,y = 7,points = [[6, 7], [7, 6], [7, 8], [8, 7]]) == 0\n assert candidate(x = 3,y = 3,points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]) == 7\n assert candidate(x = 50,y = 50,points = [[49, 50], [51, 50], [50, 49], [50, 51], [48, 50], [52, 50], [50, 48], [50, 52]]) == 0\n assert candidate(x = 7,y = 8,points = [[7, 1], [1, 8], [7, 9], [9, 8], [7, 7], [8, 8]]) == 2\n assert candidate(x = 100,y = 100,points = [[99, 100], [100, 99], [101, 100], [100, 101], [98, 100], [100, 98]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 1], [4, 4], [5, 5], [1, 3], [3, 1]]) == 2\n assert candidate(x = 1,y = 2,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 2]]) == 9\n assert candidate(x = 7,y = 7,points = [[1, 1], [1, 7], [7, 1], [7, 7], [2, 2], [6, 6], [3, 3], [5, 5], [4, 4], [8, 8]]) == 3\n assert candidate(x = 2000,y = 2000,points = [[2000, 1999], [1999, 2000], [2000, 2001], [2001, 2000], [2000, 2000], [2000, 2002], [2002, 2000]]) == 4\n assert candidate(x = 20,y = 20,points = [[20, 19], [19, 20], [21, 20], [20, 21], [20, 20], [19, 19]]) == 4\n assert candidate(x = 5,y = 5,points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == 3\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1]]) == 0\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [1, 1]]) == 5\n assert candidate(x = 7,y = 7,points = [[1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [8, 7], [9, 7], [10, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 8], [7, 9], [7, 10]]) == 5\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 1], [1, 2], [2, 1]]) == 9\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 10], [10, 2], [5, 5], [10, 10], [1, 10], [10, 1]]) == 4\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [10, 1], [10, 2], [10, 3], [1, 10], [2, 10], [3, 10]]) == 5\n assert candidate(x = 100,y = 100,points = [[100, 100], [100, 99], [99, 100], [100, 101], [101, 100], [99, 99], [101, 101]]) == 0\n assert candidate(x = 5000,y = 5000,points = [[5000, 4999], [4999, 5000], [5000, 5001], [5001, 5000], [4999, 4999], [5001, 5001]]) == 0\n assert candidate(x = 5000,y = 5000,points = [[4999, 5000], [5000, 4999], [5001, 5000], [5000, 5001], [5000, 5000]]) == 4\n assert candidate(x = 2000,y = 3000,points = [[2000, 2999], [2000, 3001], [1999, 3000], [2001, 3000], [2000, 3000]]) == 4\n assert candidate(x = 20,y = 20,points = [[20, 1], [1, 20], [19, 20], [20, 19], [20, 18], [20, 17], [20, 16], [20, 15], [20, 14], [20, 13], [20, 12], [20, 11], [20, 10], [20, 9], [20, 8], [20, 7], [20, 6], [20, 5], [20, 4], [20, 3], [20, 2]]) == 2\n assert candidate(x = 20,y = 20,points = [[15, 20], [20, 15], [25, 20], [20, 25], [10, 10], [30, 30]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 0\n assert candidate(x = 7,y = 7,points = [[7, 1], [1, 7], [7, 2], [2, 7], [7, 3], [3, 7], [7, 4], [4, 7], [7, 5], [5, 7], [7, 6], [6, 7], [7, 7]]) == 12\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [1, 2], [2, 1]]) == 4\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == 4\n assert candidate(x = 2,y = 2,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 1\n assert candidate(x = 1,y = 100,points = [[1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [2, 100], [3, 100], [4, 100], [5, 100], [6, 100]]) == 5\n assert candidate(x = 5,y = 5,points = [[5, 6], [6, 5], [5, 4], [4, 5], [5, 5], [5, 3], [3, 5], [5, 7], [7, 5]]) == 4\n assert candidate(x = 1000,y = 1000,points = [[1000, 1000], [999, 1000], [1000, 999], [999, 999], [998, 998], [997, 997], [996, 996], [995, 995], [994, 994], [993, 993]]) == 0\n assert candidate(x = 12,y = 15,points = [[10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19]]) == 2\n assert candidate(x = 7,y = 7,points = [[7, 8], [8, 7], [6, 7], [7, 6], [7, 9], [9, 7], [7, 7], [7, 5], [5, 7]]) == 6\n assert candidate(x = 20,y = 25,points = [[15, 25], [25, 20], [20, 15], [20, 30], [30, 20], [20, 20]]) == 0\n assert candidate(x = 10,y = 10,points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [10, 9], [8, 7], [6, 5], [4, 3], [2, 1]]) == 4\n assert candidate(x = 30,y = 40,points = [[30, 35], [25, 40], [30, 45], [35, 40], [30, 40], [25, 35]]) == 4\n assert candidate(x = 10,y = 10,points = [[5, 10], [15, 10], [10, 5], [10, 15], [10, 10]]) == 4\n assert candidate(x = 1,y = 1,points = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2]]) == -1\n assert candidate(x = 1,y = 1,points = [[2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20]]) == 0\n assert candidate(x = 9,y = 9,points = [[9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9], [9, 10]]) == 8\n assert candidate(x = 3,y = 3,points = [[1, 3], [3, 1], [2, 3], [3, 2], [3, 3], [4, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9]]) == 4\n assert candidate(x = 9999,y = 9999,points = [[9998, 9998], [9997, 9997], [9996, 9996], [9995, 9995], [9994, 9994], [9999, 9998], [9999, 9997], [9999, 9996], [9999, 9995], [9999, 9994], [9998, 9999], [9997, 9999], [9996, 9999], [9995, 9999], [9994, 9999]]) == 5\n assert candidate(x = 5,y = 5,points = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [1, 5], [2, 5], [3, 5], [4, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == 3\n assert candidate(x = 5000,y = 5000,points = [[1, 1], [10000, 10000], [5000, 1], [1, 5000], [5000, 5000], [4999, 4999], [5001, 5001]]) == 4\n assert candidate(x = 100,y = 1,points = [[50, 1], [60, 1], [70, 1], [80, 1], [90, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6]]) == 5\n assert candidate(x = 5000,y = 5000,points = [[4999, 5000], [5001, 5000], [5000, 4999], [5000, 5001], [4998, 5000], [5002, 5000], [5000, 4998], [5000, 5002]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1]]) == 0\n assert candidate(x = 50,y = 50,points = [[50, 50], [50, 49], [49, 50], [50, 48], [48, 50], [50, 47], [47, 50], [50, 46], [46, 50], [50, 45], [45, 50]]) == 0\n assert candidate(x = 2500,y = 7500,points = [[2500, 7499], [2500, 7501], [2499, 7500], [2501, 7500], [2498, 7500], [2502, 7500], [2500, 7498], [2500, 7502]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 1]]) == 4\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 1], [2, 2], [3, 3]]) == 4\n assert candidate(x = 10,y = 10,points = [[5, 10], [10, 5], [10, 15], [15, 10], [10, 10], [11, 10], [10, 11], [9, 10], [10, 9]]) == 4\n assert candidate(x = 5,y = 5,points = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == 3\n assert candidate(x = 6,y = 6,points = [[5, 6], [6, 5], [7, 6], [6, 7], [6, 6], [5, 5], [7, 7], [5, 7], [7, 5]]) == 4\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1]]) == 9\n assert candidate(x = 10,y = 10,points = [[10, 1], [1, 10], [10, 10], [5, 5], [10, 9], [9, 10]]) == 2\n assert candidate(x = 15,y = 20,points = [[10, 20], [15, 10], [20, 15], [15, 20], [10, 10], [20, 20]]) == 3\n assert candidate(x = 2,y = 2,points = [[2, 1], [1, 2], [3, 2], [2, 3], [1, 1], [3, 1], [1, 3], [3, 3], [2, 4], [4, 2], [4, 3], [3, 4], [4, 4]]) == 0\n assert candidate(x = 5,y = 5,points = [[5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 5], [7, 5], [8, 5], [9, 5]]) == 0\n assert candidate(x = 3,y = 3,points = [[1, 3], [2, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3], [9, 3], [10, 3], [3, 1], [3, 2], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10]]) == 1\n assert candidate(x = 7,y = 7,points = [[5, 7], [6, 8], [7, 9], [8, 6], [9, 5], [7, 7], [7, 8], [8, 7]]) == 5\n assert candidate(x = 100,y = 100,points = [[100, 50], [50, 100], [100, 60], [60, 100], [100, 70], [70, 100], [100, 80], [80, 100], [100, 90], [90, 100]]) == 8\n assert candidate(x = 7,y = 7,points = [[1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [8, 7], [9, 7], [10, 7]]) == 5\n assert candidate(x = 5000,y = 5000,points = [[5000, 5000], [5001, 5000], [4999, 5000], [5000, 5001], [5000, 4999]]) == 0\n assert candidate(x = 100,y = 100,points = [[99, 100], [100, 99], [100, 101], [101, 100], [98, 100], [100, 98], [99, 99], [101, 101]]) == 0\n assert candidate(x = 100,y = 100,points = [[50, 100], [100, 50], [150, 100], [100, 150], [100, 100]]) == 4\n assert candidate(x = 500,y = 500,points = [[500, 1], [1, 500], [500, 499], [499, 500], [10, 10], [490, 490], [50, 50], [1, 1], [500, 500]]) == 8\n assert candidate(x = 100,y = 100,points = [[100, 1], [1, 100], [99, 100], [100, 99], [10, 10], [90, 90], [50, 50], [1, 1], [100, 100]]) == 8\n assert candidate(x = 50,y = 50,points = [[50, 1], [50, 99], [1, 50], [99, 50], [50, 2], [2, 50], [50, 3], [3, 50], [50, 4], [4, 50]]) == 8\n assert candidate(x = 5000,y = 5000,points = [[4999, 4999], [5001, 5001], [4998, 5000], [5000, 4998], [5000, 5001], [5001, 5000], [4999, 5001], [5001, 4999]]) == 4\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [10, 5], [5, 10], [10, 10]]) == 5\n assert candidate(x = 100,y = 100,points = [[99, 100], [100, 99], [98, 100], [100, 98], [99, 99], [101, 100], [100, 101]]) == 0\n assert candidate(x = 5000,y = 5000,points = [[1, 1], [10000, 10000], [5000, 1], [1, 5000], [5000, 5001], [5001, 5000]]) == 4\n assert candidate(x = 100,y = 100,points = [[100, 99], [99, 100], [101, 100], [100, 101], [100, 100]]) == 4\n assert candidate(x = 10,y = 10,points = [[10, 10], [9, 10], [10, 9], [11, 10], [10, 11], [9, 9], [11, 11]]) == 0\n assert candidate(x = 7,y = 7,points = [[6, 7], [8, 7], [7, 6], [7, 8], [5, 7], [7, 5], [9, 7], [7, 9], [7, 7], [6, 6], [8, 8]]) == 8\n assert candidate(x = 5000,y = 5000,points = [[5000, 5001], [5001, 5000], [4999, 5000], [5000, 4999], [5000, 5000], [1, 1], [10000, 10000]]) == 4\n assert candidate(x = 50,y = 50,points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]]) == 4\n assert candidate(x = 3,y = 3,points = [[1, 3], [2, 3], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 3], [5, 3]]) == 4\n assert candidate(x = 10000,y = 10000,points = [[10000, 9999], [9999, 10000], [10000, 10000], [5000, 5000]]) == 2\n assert candidate(x = 25,y = 25,points = [[25, 10], [10, 25], [25, 15], [15, 25], [25, 20], [20, 25], [25, 5], [5, 25], [25, 30], [30, 25]]) == 4\n assert candidate(x = 15,y = 20,points = [[15, 1], [1, 20], [15, 3], [3, 20], [15, 4], [4, 20], [15, 5], [5, 20], [15, 6], [6, 20]]) == 9\n assert candidate(x = 20,y = 15,points = [[15, 20], [20, 15], [10, 10], [25, 25], [5, 5], [30, 30], [15, 15], [20, 20]]) == 1\n assert candidate(x = 10,y = 10,points = [[10, 1], [1, 10], [10, 10], [9, 10], [10, 9]]) == 2\n assert candidate(x = 8,y = 7,points = [[8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [8, 9], [8, 10]]) == 6\n", "comparison": "exact"}, "public_tests": ["3\n4\n[[1,2],[3,1],[2,4],[2,3],[4,4]]", "3\n4\n[[3,4]]", "3\n4\n[[2,3]]"], "hints": ["Iterate through each point, and keep track of the current point with the smallest Manhattan distance from your current location."], "metadata": {"canonical_parameter_names": ["x", "y", "points"], "leetcode_dataset_entry_point": "Solution().nearestValidPoint", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:30+00:00", "tests_total": 121, "tests_dropped": 9, "flags": [], "topic_tags": ["array"]}, "language": "javascript", "interface": {"raw_signature": "var nearestValidPoint = function(x, y, points) {", "container": null, "callable": "nearestValidPoint", "parameters": [{"name": "x", "type": "number"}, {"name": "y", "type": "number"}, {"name": "points", "type": "number[][]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1780, "task_id": "check-if-number-is-a-sum-of-powers-of-three", "difficulty": "Medium", "problem_description": "Given an integer n, return true if it is possible to represent n as the sum of distinct powers of three. Otherwise, return false.\n\nAn integer y is a power of three if there exists an integer x such that y == 3^x.\n\nExample 1:\n\nInput: n = 12\nOutput: true\nExplanation: 12 = 3^1 + 3^2\n\nExample 2:\n\nInput: n = 91\nOutput: true\nExplanation: 91 = 3^0 + 3^2 + 3^4\n\nExample 3:\n\nInput: n = 21\nOutput: false\n\nConstraints:\n\n- 1 <= n <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 59049) == True\n assert candidate(n = 3) == True\n assert candidate(n = 729) == True\n assert candidate(n = 12) == True\n assert candidate(n = 243) == True\n assert candidate(n = 21) == False\n assert candidate(n = 4782969) == True\n assert candidate(n = 19683) == True\n assert candidate(n = 1594323) == True\n assert candidate(n = 40) == True\n assert candidate(n = 59048) == False\n assert candidate(n = 1093) == True\n assert candidate(n = 10000000) == False\n assert candidate(n = 100000) == False\n assert candidate(n = 27) == True\n assert candidate(n = 6561) == True\n assert candidate(n = 3645) == False\n assert candidate(n = 2187) == True\n assert candidate(n = 177147) == True\n assert candidate(n = 91) == True\n assert candidate(n = 81) == True\n assert candidate(n = 531441) == True\n assert candidate(n = 1000000) == False\n assert candidate(n = 1000001) == False\n assert candidate(n = 9) == True\n assert candidate(n = 98415) == False\n assert candidate(n = 1) == True\n assert candidate(n = 10) == True\n assert candidate(n = 89076) == False\n assert candidate(n = 9999999) == False\n assert candidate(n = 98416) == False\n assert candidate(n = 39856) == False\n assert candidate(n = 1640261) == False\n assert candidate(n = 59050) == True\n assert candidate(n = 9876543) == False\n assert candidate(n = 32804) == False\n assert candidate(n = 819) == True\n assert candidate(n = 9841) == True\n assert candidate(n = 8) == False\n assert candidate(n = 810000) == False\n assert candidate(n = 8191) == False\n assert candidate(n = 72900) == False\n assert candidate(n = 524880) == False\n assert candidate(n = 7290) == True\n assert candidate(n = 11) == False\n assert candidate(n = 1048575) == False\n assert candidate(n = 59250) == False\n assert candidate(n = 109355) == False\n assert candidate(n = 10935) == False\n assert candidate(n = 98414) == False\n assert candidate(n = 2391484) == True\n assert candidate(n = 88572) == True\n assert candidate(n = 32805) == False\n assert candidate(n = 88573) == True\n assert candidate(n = 50000) == False\n assert candidate(n = 1049755) == False\n assert candidate(n = 590490) == True\n assert candidate(n = 4) == True\n assert candidate(n = 98411) == False\n assert candidate(n = 6560) == False\n assert candidate(n = 4100) == False\n assert candidate(n = 19684) == True\n assert candidate(n = 531442) == True\n assert candidate(n = 49308) == False\n assert candidate(n = 39858) == False\n assert candidate(n = 59047) == False\n assert candidate(n = 99018) == False\n assert candidate(n = 98409) == False\n assert candidate(n = 58324) == False\n assert candidate(n = 48619) == False\n assert candidate(n = 69192) == False\n assert candidate(n = 369059) == False\n assert candidate(n = 4052555) == False\n assert candidate(n = 1291401) == False\n assert candidate(n = 98413) == False\n assert candidate(n = 131220) == False\n assert candidate(n = 437400) == False\n assert candidate(n = 2) == False\n assert candidate(n = 4000000) == False\n assert candidate(n = 981) == True\n assert candidate(n = 97656) == False\n assert candidate(n = 3986) == False\n assert candidate(n = 19682) == False\n assert candidate(n = 797162) == False\n assert candidate(n = 656100) == False\n assert candidate(n = 45927) == False\n assert candidate(n = 79134) == False\n assert candidate(n = 1234567) == False\n assert candidate(n = 3125) == False\n assert candidate(n = 2097152) == False\n assert candidate(n = 98410) == False\n assert candidate(n = 99999) == False\n assert candidate(n = 728997) == False\n assert candidate(n = 405224) == False\n assert candidate(n = 31259) == False\n assert candidate(n = 119050) == False\n assert candidate(n = 104976) == False\n assert candidate(n = 546789) == False\n assert candidate(n = 39366) == False\n assert candidate(n = 40000) == False\n assert candidate(n = 29524) == True\n assert candidate(n = 98412) == False\n assert candidate(n = 400) == False\n assert candidate(n = 32806) == False\n assert candidate(n = 3188646) == False\n assert candidate(n = 123456) == False\n", "comparison": "exact"}, "public_tests": ["12", "91", "21"], "hints": ["Let's note that the maximum power of 3 you'll use in your soln is 3^16", "The number can not be represented as a sum of powers of 3 if it's ternary presentation has a 2 in it"], "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().checkPowersOfThree", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:33+00:00", "tests_total": 110, "tests_dropped": 4, "flags": [], "topic_tags": ["math"]}, "language": "javascript", "interface": {"raw_signature": "var checkPowersOfThree = function(n) {", "container": null, "callable": "checkPowersOfThree", "parameters": [{"name": "n", "type": "number"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1781, "task_id": "sum-of-beauty-of-all-substrings", "difficulty": "Medium", "problem_description": "The beauty of a string is the difference in frequencies between the most frequent and least frequent characters.\n\n- For example, the beauty of \"abaacc\" is 3 - 1 = 2.\n\nGiven a string s, return the sum of beauty of all of its substrings.\n\nExample 1:\n\nInput: s = \"aabcb\"\nOutput: 5\nExplanation: The substrings with non-zero beauty are [\"aab\",\"aabc\",\"aabcb\",\"abcb\",\"bcb\"], each with beauty equal to 1.\n\nExample 2:\n\nInput: s = \"aabcbaa\"\nOutput: 17\n\nConstraints:\n\n- 1 <= s.length <=500\n- s consists of only lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"xyzzxyzzxyzz\") == 87\n assert candidate(s = \"aaabbbccc\") == 29\n assert candidate(s = \"aabcb\") == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(s = \"abcdedcba\") == 16\n assert candidate(s = \"a\") == 0\n assert candidate(s = \"abcabcabc\") == 16\n assert candidate(s = \"zzzz\") == 0\n assert candidate(s = \"aabcbaa\") == 17\n assert candidate(s = \"pqrspqrspqrspqrs\") == 63\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\") == 0\n assert candidate(s = \"xyzxyzxyz\") == 16\n assert candidate(s = \"abcdabcdabcd\") == 30\n assert candidate(s = \"abc\") == 0\n assert candidate(s = \"xyzzxyzz\") == 25\n assert candidate(s = \"abcd\") == 0\n assert candidate(s = \"aabbccddeeff\") == 40\n assert candidate(s = \"zzzzz\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 950\n assert candidate(s = \"abcdefg\") == 0\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\") == 1112\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == 432\n assert candidate(s = \"pqrstuvwxyzabcdefghijklmno\") == 0\n assert candidate(s = \"abccbaabccbaabccbaabccba\") == 222\n assert candidate(s = \"verycomplicatedstringwithrepeatedcharactersrepeatedrepeated\") == 5556\n assert candidate(s = \"mississippimississippimississippimississippi\") == 4387\n assert candidate(s = \"abracadabra\") == 64\n assert candidate(s = \"abacabadabacabadabacabadabacabad\") == 2236\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacaba\") == 11131\n assert candidate(s = \"abcabcabcabc\") == 33\n assert candidate(s = \"xzyxzxyzxyz\") == 34\n assert candidate(s = \"abcdefabcdeabcdeabcde\") == 183\n assert candidate(s = \"aabacababa\") == 66\n assert candidate(s = \"zzzzzzzzzz\") == 0\n assert candidate(s = \"abcdefghijklmabcdefghijklm\") == 90\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 1170\n assert candidate(s = \"abababababababababababababababab\") == 240\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabc\") == 456\n assert candidate(s = \"mississippiissiippiisppiiiiiiii\") == 1732\n assert candidate(s = \"abacabadabacabadabacabadabacaba\") == 2047\n assert candidate(s = \"thisisaverylongandcomplicatedstringwithvariouscharacters\") == 2645\n assert candidate(s = \"mnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == 325\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 513\n assert candidate(s = \"kayak\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 261\n assert candidate(s = \"xyzzzzxyzzzzxyzzzzxyzzzz\") == 1254\n assert candidate(s = \"ababababababab\") == 42\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\") == 1\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdef\") == 400\n assert candidate(s = \"abcdabcdabcdabcd\") == 63\n assert candidate(s = \"level\") == 4\n assert candidate(s = \"ppppppppppppppppppppppppppppppppppqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 13090\n assert candidate(s = \"xyzzyxzyxzyzyx\") == 87\n assert candidate(s = \"pqrsrstsrqpqrs\") == 102\n assert candidate(s = \"madam\") == 4\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 1053\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwerty\") == 21\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 2450\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggg\") == 630\n assert candidate(s = \"abacabadabacaba\") == 231\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\") == 702\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 44628\n assert candidate(s = \"xyzzazxzy\") == 45\n assert candidate(s = \"abababababababababababababababababababababababab\") == 552\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccccccc\") == 1275\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 1350\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjaabbccddeeffgghhiijjaabbccddeeffgghhiijj\") == 2118\n assert candidate(s = \"bananaananabananananabananananananananananananana\") == 7610\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 0\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"banana\") == 8\n assert candidate(s = \"xyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzz\") == 11722\n assert candidate(s = \"mnopqrsmnopqrsmnopqrsmnopqrsmnopqrsmnopqrsmnopqrsmnopqrs\") == 1071\n assert candidate(s = \"aabbccddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxxyyyzzz\") == 4312\n assert candidate(s = \"aaaaabbbbccccddddeeeffffggghhh\") == 782\n assert candidate(s = \"nnnnoonnmnmlmllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll\") == 33629\n assert candidate(s = \"aaaabbbbccccdddd\") == 162\n assert candidate(s = \"abacabadabacabadabacabad\") == 948\n assert candidate(s = \"deified\") == 9\n assert candidate(s = \"zzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"repaper\") == 9\n assert candidate(s = \"xyzzzzzxyzzzzzxyzzzzzxyzzzzzxyzzzzzxyzzzzzxyzzzzzxyzzzzz\") == 17541\n assert candidate(s = \"aabbaaabbbaaabbaaaabbbaaabbaaaabbbaaabbaaaabbbaaabbaaaab\") == 5129\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzz\") == 11950\n assert candidate(s = \"aabbccddeeffgghhiijjanmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 1979\n assert candidate(s = \"abababababababababababab\") == 132\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 350\n assert candidate(s = \"rotor\") == 4\n assert candidate(s = \"racecar\") == 9\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 320\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == 161\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 350\n assert candidate(s = \"reviled\") == 4\n assert candidate(s = \"mnopqrnopqmonmnopq\") == 145\n assert candidate(s = \"abacabadaba\") == 85\n assert candidate(s = \"mississippi\") == 64\n assert candidate(s = \"aaaaabbbbccccddddeeeffffgggghhhhiiiiijjjjkkkkllllmmmmmnnnnnooooo\") == 4941\n assert candidate(s = \"abcabcabcabcabc\") == 56\n assert candidate(s = \"xyzzzzzxyzzzzzxyzzzzz\") == 936\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"refer\") == 4\n", "comparison": "exact"}, "public_tests": ["\"aabcb\"", "\"aabcbaa\""], "hints": ["Maintain a prefix sum for the frequencies of characters.", "You can iterate over all substring then iterate over the alphabet and find which character appears most and which appears least using the prefix sum array"], "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().beautySum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:30:35+00:00", "tests_total": 103, "tests_dropped": 0, "flags": [], "topic_tags": ["hash-table", "string", "counting"]}, "language": "javascript", "interface": {"raw_signature": "var beautySum = function(s) {", "container": null, "callable": "beautySum", "parameters": [{"name": "s", "type": "string"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} @@ -129,7 +128,7 @@ {"question_id": 1817, "task_id": "finding-the-users-active-minutes", "difficulty": "Medium", "problem_description": "You are given the logs for users' actions on LeetCode, and an integer k. The logs are represented by a 2D integer array logs where each logs[i] = [ID_i, time_i] indicates that the user with ID_i performed an action at the minute time_i.\n\nMultiple users can perform actions simultaneously, and a single user can perform multiple actions in the same minute.\n\nThe user active minutes (UAM) for a given user is defined as the number of unique minutes in which the user performed an action on LeetCode. A minute can only be counted once, even if multiple actions occur during it.\n\nYou are to calculate a 1-indexed array answer of size k such that, for each j (1 <= j <= k), answer[j] is the number of users whose UAM equals j.\n\nReturn the array answer as described above.\n\nExample 1:\n\nInput: logs = [[0,5],[1,2],[0,2],[0,5],[1,3]], k = 5\nOutput: [0,2,0,0,0]\nExplanation:\nThe user with ID=0 performed actions at minutes 5, 2, and 5 again. Hence, they have a UAM of 2 (minute 5 is only counted once).\nThe user with ID=1 performed actions at minutes 2 and 3. Hence, they have a UAM of 2.\nSince both users have a UAM of 2, answer[2] is 2, and the remaining answer[j] values are 0.\n\nExample 2:\n\nInput: logs = [[1,1],[2,2],[2,3]], k = 4\nOutput: [1,1,0,0]\nExplanation:\nThe user with ID=1 performed a single action at minute 1. Hence, they have a UAM of 1.\nThe user with ID=2 performed actions at minutes 2 and 3. Hence, they have a UAM of 2.\nThere is one user with a UAM of 1 and one with a UAM of 2.\nHence, answer[1] = 1, answer[2] = 1, and the remaining values are 0.\n\nConstraints:\n\n- 1 <= logs.length <= 10^4\n- 0 <= ID_i <= 10^9\n- 1 <= time_i <= 10^5\n- k is in the range [The maximum UAM for a user, 10^5].\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],k = 3) == [0, 0, 3]\n assert candidate(logs = [[10, 1], [11, 2], [10, 2], [11, 3], [10, 3], [11, 4]],k = 4) == [0, 0, 2, 0]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],k = 5) == [0, 0, 0, 0, 1]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3]],k = 3) == [0, 0, 2]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1]],k = 1) == [4]\n assert candidate(logs = [[1, 1], [2, 2], [2, 3]],k = 4) == [1, 1, 0, 0]\n assert candidate(logs = [[10, 10], [10, 10], [10, 11], [11, 12]],k = 3) == [1, 1, 0]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],k = 5) == [5, 0, 0, 0, 0]\n assert candidate(logs = [[0, 10], [0, 10], [1, 10], [1, 11], [1, 12]],k = 3) == [1, 0, 1]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4]],k = 4) == [4, 0, 0, 0]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],k = 5) == [5, 0, 0, 0, 0]\n assert candidate(logs = [[0, 5], [1, 2], [0, 2], [0, 5], [1, 3]],k = 5) == [0, 2, 0, 0, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],k = 1) == [1]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1]],k = 1) == [5]\n assert candidate(logs = [[10, 10], [10, 10], [10, 11], [10, 12], [11, 10], [11, 11]],k = 3) == [0, 1, 1]\n assert candidate(logs = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10], [110, 10], [120, 10], [130, 10], [140, 10], [150, 10]],k = 1) == [15]\n assert candidate(logs = [[100, 1], [101, 1], [102, 2], [103, 2], [104, 3], [105, 3], [106, 4], [107, 4], [108, 5], [109, 5]],k = 5) == [10, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 10) == [0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [0, 16], [1, 17], [2, 18], [3, 19], [4, 20]],k = 15) == [10, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15]],k = 5) == [5, 5, 0, 0, 0]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],k = 5) == [5, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],k = 3) == [0, 0, 4]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],k = 5) == [0, 0, 0, 0, 2]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 10) == [10, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [5, 1], [5, 2], [5, 3]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]],k = 2) == [0, 5]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [0, 4], [1, 5], [2, 6], [0, 7], [1, 8], [2, 9], [0, 10], [1, 11], [2, 12], [0, 13], [1, 14], [2, 15]],k = 5) == [0, 0, 0, 0, 3]\n assert candidate(logs = [[5, 1], [5, 1], [5, 1], [5, 1], [5, 1], [6, 2], [6, 2], [6, 2], [6, 3], [6, 4], [6, 5], [7, 3], [7, 3], [7, 3], [7, 3], [7, 3], [7, 3], [7, 3], [7, 3], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4]],k = 5) == [3, 0, 0, 1, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [1, 2], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]],k = 5) == [0, 0, 1, 1, 1]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19]],k = 10) == [0, 0, 0, 0, 1, 0, 0, 0, 1, 1]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]],k = 15) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[100, 1], [101, 1], [102, 2], [103, 2], [104, 2], [105, 3], [106, 3], [107, 3], [108, 4], [109, 4]],k = 4) == [10, 0, 0, 0]\n assert candidate(logs = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15]],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(logs = [[0, 10], [1, 20], [0, 10], [1, 25], [2, 30], [3, 35], [4, 40], [5, 45], [6, 50], [7, 55], [8, 60], [9, 65]],k = 10) == [9, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2], [11, 3], [12, 3], [13, 3], [14, 3], [15, 3]],k = 3) == [15, 0, 0]\n assert candidate(logs = [[9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9], [9, 10], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 2]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 2]\n assert candidate(logs = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [0, 1100], [1, 1200], [2, 1300], [3, 1400], [4, 1500], [5, 1600], [6, 1700], [7, 1800], [8, 1900], [9, 2000]],k = 10) == [0, 10, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[10, 5], [10, 5], [10, 6], [10, 7], [11, 5], [11, 6], [11, 7], [12, 5], [12, 6], [12, 7], [13, 5], [13, 6], [13, 7]],k = 3) == [0, 0, 4]\n assert candidate(logs = [[0, 10], [1, 10], [2, 10], [0, 11], [1, 11], [2, 11], [0, 12], [1, 12], [2, 12]],k = 3) == [0, 0, 3]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]],k = 1) == [10]\n assert candidate(logs = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [101, 1], [101, 2], [101, 3], [101, 4], [101, 5], [102, 1], [102, 2], [102, 3], [102, 4], [102, 5], [103, 1], [103, 2], [103, 3], [103, 4], [103, 5]],k = 5) == [0, 0, 0, 0, 4]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [0, 11], [1, 12], [2, 13], [3, 14], [4, 15], [5, 16], [6, 17], [7, 18], [8, 19], [9, 20]],k = 10) == [0, 10, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 5], [0, 5], [0, 5], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 1], [2, 1], [2, 2]],k = 5) == [1, 1, 0, 1, 0]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8]],k = 5) == [0, 0, 0, 5, 0]\n assert candidate(logs = [[99, 99], [99, 100], [99, 101], [99, 102], [99, 103], [99, 104], [99, 105]],k = 7) == [0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 11], [120, 12], [130, 13], [140, 14], [150, 15]],k = 15) == [15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 2]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 10) == [0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(logs = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5]],k = 5) == [0, 0, 0, 0, 3]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [0, 3], [1, 3], [2, 3], [3, 3], [4, 3]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15]],k = 15) == [0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[10, 100], [11, 101], [10, 101], [11, 102], [12, 102], [13, 103], [13, 104], [14, 104], [14, 105], [15, 106], [15, 106], [15, 107]],k = 5) == [1, 5, 0, 0, 0]\n assert candidate(logs = [[0, 10], [0, 10], [0, 11], [1, 12], [1, 12], [1, 13], [2, 14], [2, 15], [2, 15], [2, 16]],k = 4) == [0, 2, 1, 0]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]],k = 2) == [0, 11]\n assert candidate(logs = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1]],k = 1) == [1]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],k = 20) == [20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 5) == [0, 0, 0, 0, 2]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]],k = 5) == [0, 0, 0, 0, 3]\n assert candidate(logs = [[0, 1], [0, 2], [1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2], [4, 1], [4, 2], [5, 1], [5, 2]],k = 2) == [0, 6]\n assert candidate(logs = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5], [11, 5], [12, 5], [13, 5], [14, 5]],k = 1) == [15]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [0, 11]],k = 11) == [9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [0, 3], [1, 3], [2, 3], [3, 3], [4, 3], [0, 4], [1, 4], [2, 4], [3, 4], [4, 4], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [0, 6], [1, 6], [2, 6], [3, 6], [4, 6]],k = 6) == [0, 0, 0, 0, 0, 5]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [0, 2], [1, 2], [2, 2], [0, 3], [1, 3], [2, 3], [0, 4], [1, 4], [2, 4], [0, 5], [1, 5], [2, 5], [0, 6], [1, 6], [2, 6]],k = 6) == [0, 0, 0, 0, 0, 3]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 5) == [0, 0, 1, 1, 1]\n assert candidate(logs = [[10, 1], [10, 2], [10, 3], [20, 1], [20, 2], [30, 1], [30, 2], [30, 3], [40, 1], [40, 2], [40, 3], [50, 1], [50, 2], [50, 3], [60, 1], [60, 2]],k = 3) == [0, 2, 4]\n assert candidate(logs = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [1, 12], [2, 12], [3, 12], [4, 12], [5, 12]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[0, 1], [0, 2], [0, 1], [0, 2], [0, 1], [0, 2], [0, 1], [0, 2], [0, 1], [0, 2], [0, 3], [0, 4]],k = 5) == [0, 0, 0, 1, 0]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],k = 2) == [5, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [5, 1], [5, 2], [5, 3], [6, 1], [6, 2], [6, 3]],k = 3) == [0, 0, 7]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],k = 10) == [0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(logs = [[1, 1], [2, 2], [2, 2], [2, 3], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]],k = 4) == [4, 1, 0, 0]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [4, 1], [4, 2], [4, 3], [4, 4]],k = 4) == [0, 0, 0, 4]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]],k = 1) == [15]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20]],k = 20) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1]],k = 1) == [1]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [5, 6], [5, 7], [5, 8], [6, 9]],k = 5) == [4, 1, 1, 0, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]],k = 1) == [5]\n assert candidate(logs = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5]],k = 1) == [10]\n assert candidate(logs = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [3, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16]],k = 6) == [0, 2, 1, 1, 1, 0]\n assert candidate(logs = [[10, 10], [10, 10], [20, 20], [20, 21], [20, 22], [30, 30], [30, 30], [30, 31]],k = 3) == [1, 1, 1]\n assert candidate(logs = [[0, 1], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6]],k = 6) == [1, 0, 1, 1, 1, 1]\n assert candidate(logs = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2], [4, 1], [4, 2], [5, 1], [5, 2], [6, 1], [6, 2], [7, 1], [7, 2], [8, 1], [8, 2], [9, 1], [9, 2], [10, 1], [10, 2]],k = 2) == [0, 10]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8]],k = 8) == [0, 0, 0, 0, 1, 0, 1, 1]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [1, 16]],k = 6) == [0, 0, 4, 1, 0, 0]\n assert candidate(logs = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [10, 11], [20, 12], [30, 13], [40, 14], [50, 15], [60, 16], [70, 17], [80, 18], [90, 19], [100, 20]],k = 10) == [0, 10, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[0, 1], [0, 1], [0, 1], [0, 2], [0, 2], [0, 2], [0, 3], [0, 3], [0, 3], [0, 4], [0, 4], [0, 4], [0, 5], [0, 5], [0, 5]],k = 5) == [0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [0, 11], [1, 12], [2, 13], [3, 14], [4, 15]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]],k = 15) == [15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [4, 18], [4, 19], [4, 20]],k = 7) == [1, 0, 2, 0, 0, 1, 1]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]],k = 5) == [0, 0, 1, 1, 1]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [0, 11], [1, 12], [2, 13], [3, 14], [4, 15]],k = 5) == [0, 0, 5, 0, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 2], [2, 1], [2, 1], [2, 2], [2, 3], [3, 1], [3, 1], [3, 2], [3, 3], [3, 4]],k = 4) == [0, 1, 1, 1]\n assert candidate(logs = [[0, 1], [0, 1], [1, 1], [1, 1], [2, 1], [2, 1], [3, 1], [3, 1], [4, 1], [4, 1]],k = 1) == [5]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 5) == [0, 0, 0, 0, 3]\n assert candidate(logs = [[10, 10], [20, 10], [10, 20], [20, 20], [10, 30], [20, 40], [30, 50]],k = 5) == [1, 0, 2, 0, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 2], [4, 1], [4, 2], [4, 3], [4, 4]],k = 4) == [1, 1, 1, 1]\n assert candidate(logs = [[100, 1], [101, 2], [102, 3], [103, 4], [104, 5], [105, 6], [106, 7], [107, 8], [108, 9], [109, 10]],k = 10) == [10, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],k = 3) == [0, 1, 3]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [1, 2], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1]],k = 1) == [20]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20]],k = 20) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],k = 1) == [11]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [1, 2], [2, 2], [3, 2], [1, 3], [2, 3], [3, 3], [1, 4], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5], [1, 6], [2, 6], [3, 6], [1, 7], [2, 7], [3, 7]],k = 7) == [0, 0, 0, 0, 0, 0, 3]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 5) == [0, 0, 0, 0, 3]\n", "comparison": "exact"}, "public_tests": ["[[0,5],[1,2],[0,2],[0,5],[1,3]]\n5", "[[1,1],[2,2],[2,3]]\n4"], "hints": ["Try to find the number of different minutes when action happened for each user.", "For each user increase the value of the answer array index which matches the UAM for this user."], "metadata": {"canonical_parameter_names": ["logs", "k"], "leetcode_dataset_entry_point": "Solution().findingUsersActiveMinutes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:39+00:00", "tests_total": 108, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table"]}, "language": "javascript", "interface": {"raw_signature": "var findingUsersActiveMinutes = function(logs, k) {", "container": null, "callable": "findingUsersActiveMinutes", "parameters": [{"name": "logs", "type": "number[][]"}, {"name": "k", "type": "number"}], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1818, "task_id": "minimum-absolute-sum-difference", "difficulty": "Medium", "problem_description": "You are given two positive integer arrays nums1 and nums2, both of length n.\n\nThe absolute sum difference of arrays nums1 and nums2 is defined as the sum of |nums1[i] - nums2[i]| for each 0 <= i < n (0-indexed).\n\nYou can replace at most one element of nums1 with any other element in nums1 to minimize the absolute sum difference.\n\nReturn the minimum absolute sum difference after replacing at most one element in the array nums1. Since the answer may be large, return it modulo 10^9 + 7.\n\n|x| is defined as:\n\n- x if x >= 0, or\n- -x if x < 0.\n\nExample 1:\n\nInput: nums1 = [1,7,5], nums2 = [2,3,5]\nOutput: 3\nExplanation: There are two possible optimal solutions:\n- Replace the second element with the first: [1,7,5] => [1,1,5], or\n- Replace the second element with the third: [1,7,5] => [1,5,5].\nBoth will yield an absolute sum difference of |1-2| + (|1-3| or |5-3|) + |5-5| = 3.\n\nExample 2:\n\nInput: nums1 = [2,4,6,8,10], nums2 = [2,4,6,8,10]\nOutput: 0\nExplanation: nums1 is equal to nums2 so no replacement is needed. This will result in an\nabsolute sum difference of 0.\n\nExample 3:\n\nInput: nums1 = [1,10,4,4,2,7], nums2 = [9,3,5,1,7,4]\nOutput: 20\nExplanation: Replace the first element with the second: [1,10,4,4,2,7] => [10,10,4,4,2,7].\nThis yields an absolute sum difference of |10-9| + |10-3| + |4-5| + |4-1| + |2-7| + |7-4| = 20\n\nConstraints:\n\n- n == nums1.length\n- n == nums2.length\n- 1 <= n <= 10^5\n- 1 <= nums1[i], nums2[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [100000, 100000, 100000],nums2 = [1, 1, 1]) == 299997\n assert candidate(nums1 = [1, 7, 5],nums2 = [2, 3, 5]) == 3\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1]) == 16\n assert candidate(nums1 = [100000, 100000, 100000],nums2 = [1, 1, 1]) == 299997\n assert candidate(nums1 = [1, 10, 4, 4, 2, 7],nums2 = [9, 3, 5, 1, 7, 4]) == 20\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [2, 4, 6, 8, 10]) == 0\n assert candidate(nums1 = [1, 2, 3],nums2 = [6, 5, 4]) == 7\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 8\n assert candidate(nums1 = [100000, 1, 100000],nums2 = [1, 100000, 1]) == 199998\n assert candidate(nums1 = [1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000],nums2 = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1]) == 899991\n assert candidate(nums1 = [100000, 99999, 99998, 99997],nums2 = [1, 2, 3, 4]) == 399981\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1]) == 15\n assert candidate(nums1 = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 999881\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 999945\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 90\n assert candidate(nums1 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 945\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 5\n assert candidate(nums1 = [100000, 99999, 99998, 99997, 99996],nums2 = [1, 2, 3, 4, 5]) == 499971\n assert candidate(nums1 = [100000, 100000, 100000, 100000],nums2 = [1, 100000, 100000, 1]) == 199998\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 41\n assert candidate(nums1 = [50000, 50000, 50000, 50000, 50000],nums2 = [1, 2, 3, 4, 5]) == 249985\n assert candidate(nums1 = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996],nums2 = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5]) == 899951\n assert candidate(nums1 = [100000, 1, 50000, 75000],nums2 = [50000, 99999, 1, 100000]) == 125000\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums1 = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],nums2 = [90, 80, 70, 60, 50, 40, 30, 20, 10, 1]) == 409\n assert candidate(nums1 = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996],nums2 = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5]) == 899951\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [45, 40, 35, 30, 25, 20, 15, 10, 5, 1]) == 204\n assert candidate(nums1 = [50000, 50000, 50000, 50000, 50000],nums2 = [1, 1, 1, 1, 1]) == 249995\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 10\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [1, 3, 6, 8, 11, 13, 16, 18, 21, 23]) == 130\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 98\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999]) == 999980\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 499936\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5]) == 95\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 36\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 16\n assert candidate(nums1 = [100000, 100000, 100000],nums2 = [90000, 90000, 90000]) == 30000\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 210\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]) == 500\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 41\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 50\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 32\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 181\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 82\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == 25\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == 8\n assert candidate(nums1 = [1, 10, 100, 1000, 10000, 100000],nums2 = [100000, 10000, 1000, 100, 10, 1]) == 121779\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 486\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 410\n assert candidate(nums1 = [100, 100, 100, 100, 100],nums2 = [10, 90, 110, 10, 90]) == 210\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 999990\n assert candidate(nums1 = [100000, 100000, 100000, 100000],nums2 = [1, 1, 1, 1]) == 399996\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 50\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 67\n assert candidate(nums1 = [1, 10, 100, 1000, 10000],nums2 = [2, 11, 101, 1001, 10001]) == 5\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 405\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 5\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 549990\n assert candidate(nums1 = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 999891\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 20\n assert candidate(nums1 = [99999, 99998, 99997, 99996, 99995],nums2 = [1, 100, 200, 300, 400]) == 498980\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 9\n assert candidate(nums1 = [50000, 40000, 30000, 20000, 10000],nums2 = [1, 2, 3, 4, 5]) == 109985\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 171\n assert candidate(nums1 = [100000, 90000, 80000, 70000, 60000],nums2 = [50000, 40000, 30000, 20000, 10000]) == 210000\n assert candidate(nums1 = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 99943\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [101, 201, 301, 401, 501]) == 5\n assert candidate(nums1 = [5, 25, 45, 65, 85],nums2 = [10, 30, 50, 70, 90]) == 25\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 82\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 891\n assert candidate(nums1 = [100000, 100000, 100000, 100000, 100000],nums2 = [1, 1, 1, 1, 1]) == 499995\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 540\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [15, 25, 35, 45, 55]) == 25\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 20\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 999882\n assert candidate(nums1 = [100000, 50000, 25000, 12500, 6250],nums2 = [99999, 49999, 24999, 12499, 6249]) == 5\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 55\n", "comparison": "exact"}, "public_tests": ["[1,7,5]\n[2,3,5]", "[2,4,6,8,10]\n[2,4,6,8,10]", "[1,10,4,4,2,7]\n[9,3,5,1,7,4]"], "hints": ["Go through each element and test the optimal replacements.", "There are only 2 possible replacements for each element (higher and lower) that are optimal."], "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minAbsoluteSumDiff", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:41+00:00", "tests_total": 87, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "binary-search", "sorting", "ordered-set"]}, "language": "javascript", "interface": {"raw_signature": "var minAbsoluteSumDiff = function(nums1, nums2) {", "container": null, "callable": "minAbsoluteSumDiff", "parameters": [{"name": "nums1", "type": "number[]"}, {"name": "nums2", "type": "number[]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1819, "task_id": "number-of-different-subsequences-gcds", "difficulty": "Hard", "problem_description": "You are given an array nums that consists of positive integers.\n\nThe GCD of a sequence of numbers is defined as the greatest integer that divides all the numbers in the sequence evenly.\n\n- For example, the GCD of the sequence [4,6,16] is 2.\n\nA subsequence of an array is a sequence that can be formed by removing some elements (possibly none) of the array.\n\n- For example, [2,5,10] is a subsequence of [1,2,1,2,4,1,5,10].\n\nReturn the number of different GCDs among all non-empty subsequences of nums.\n\nExample 1:\n\nInput: nums = [6,10,3]\nOutput: 5\nExplanation: The figure shows all the non-empty subsequences and their GCDs.\nThe different GCDs are 6, 10, 3, 2, and 1.\n\nExample 2:\n\nInput: nums = [5,15,40,5,6]\nOutput: 7\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 2 * 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [6, 10, 3]) == 5\n assert candidate(nums = [2, 4, 6, 8, 10]) == 5\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [5, 15, 40, 5, 6]) == 7\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [7, 7, 7, 7, 7]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500]) == 5\n assert candidate(nums = [7, 14, 21, 28, 35]) == 5\n assert candidate(nums = [100000]) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 11\n assert candidate(nums = [100000, 200000, 150000]) == 4\n assert candidate(nums = [7, 7, 7, 7]) == 1\n assert candidate(nums = [30, 15, 60, 90, 180]) == 5\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840, 882, 924, 966, 1008, 1050]) == 25\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 50\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 20\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 15\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 10\n assert candidate(nums = [37, 74, 111, 148, 185, 222, 259, 296, 333, 370, 407, 444, 481, 518, 555, 592, 629, 666, 703, 740, 777, 814, 851, 888, 925, 962, 999]) == 27\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630]) == 15\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717, 1818, 1919, 2020]) == 20\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175]) == 18\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 30\n assert candidate(nums = [10, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205]) == 22\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]) == 15\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 15\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120]) == 20\n assert candidate(nums = [5, 25, 45, 65, 85, 105, 125, 145, 165, 185, 205, 225, 245, 265, 285, 305, 325, 345, 365, 385]) == 23\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225, 234, 243, 252, 261, 270]) == 30\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197]) == 21\n assert candidate(nums = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30]) == 34\n assert candidate(nums = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111]) == 25\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 10\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 10\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993]) == 16\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 20\n assert candidate(nums = [12, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 26\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260, 273, 286, 299, 312, 325, 338, 351, 364, 377, 390]) == 30\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225]) == 25\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == 16\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]) == 20\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96]) == 24\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515]) == 15\n assert candidate(nums = [37, 74, 111, 148, 185, 222, 259, 296, 333, 370, 407, 444, 481, 518, 555, 592, 629, 666, 703, 740]) == 20\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 25\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 25\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231, 242, 253, 264, 275, 286, 297, 308, 319, 330]) == 30\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 20\n assert candidate(nums = [104729, 104728, 104727, 104726, 104725, 104724, 104723, 104722, 104721, 104720, 104719, 104718, 104717, 104716, 104715]) == 25\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 20\n assert candidate(nums = [97, 194, 291, 388, 485, 582, 679, 776, 873, 970, 1067, 1164, 1261, 1358, 1455, 1552, 1649, 1746, 1843, 1940]) == 20\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == 16\n assert candidate(nums = [15, 21, 25, 33, 35, 39, 45, 51, 55, 57, 63, 65, 69, 75, 77, 81, 85, 87, 91, 93, 95, 99]) == 31\n assert candidate(nums = [37, 74, 111, 148, 185, 222, 259, 296, 333, 370, 407, 444, 481, 518, 555]) == 15\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54]) == 18\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == 21\n assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600]) == 10\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300]) == 25\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 15\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 26\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]) == 14\n assert candidate(nums = [99995, 99996, 99997, 99998, 99999, 100000, 100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009]) == 26\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 20\n assert candidate(nums = [71, 142, 213, 284, 355, 426, 497, 568, 639, 710, 781, 852, 923, 994, 1065, 1136, 1207, 1278, 1349]) == 19\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510, 540, 570, 600]) == 20\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 15\n assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 660, 720, 780, 840, 900, 960, 1020, 1080, 1140, 1200]) == 20\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 30\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == 20\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 10\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300, 315, 330, 345, 360, 375, 390, 405, 420, 435, 450]) == 30\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 1\n assert candidate(nums = [120, 240, 360, 480, 600, 720, 840, 960, 1080, 1200, 1320, 1440, 1560, 1680, 1800, 1920, 2040]) == 17\n assert candidate(nums = [21, 35, 49, 63, 77, 91, 105, 119, 133, 147]) == 11\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99]) == 33\n assert candidate(nums = [200000, 199999, 199998, 199997, 199996, 199995, 199994, 199993, 199992, 199991]) == 17\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300]) == 20\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 1\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340]) == 20\n assert candidate(nums = [30, 42, 54, 60, 72, 84, 90, 102, 105, 108, 120, 126, 132, 144, 150, 156, 162, 168, 180, 192]) == 29\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015]) == 27\n", "comparison": "exact"}, "public_tests": ["[6,10,3]", "[5,15,40,5,6]"], "hints": ["Think of how to check if a number x is a gcd of a subsequence.", "If there is such subsequence, then all of it will be divisible by x. Moreover, if you divide each number in the subsequence by x , then the gcd of the resulting numbers will be 1.", "Adding a number to a subsequence cannot increase its gcd. So, if there is a valid subsequence for x , then the subsequence that contains all multiples of x is a valid one too.", "Iterate on all possiblex from 1 to 10^5, and check if there is a valid subsequence for x."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countDifferentSubsequenceGCDs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:44+00:00", "tests_total": 101, "tests_dropped": 3, "flags": ["has_images"], "topic_tags": ["array", "math", "counting", "number-theory", "euclidean-algorithm", "greatest-common-divisor"]}, "language": "javascript", "interface": {"raw_signature": "var countDifferentSubsequenceGCDs = function(nums) {", "container": null, "callable": "countDifferentSubsequenceGCDs", "parameters": [{"name": "nums", "type": "number[]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 1822, "task_id": "sign-of-the-product-of-an-array", "difficulty": "Easy", "problem_description": "Implement a function signFunc(x) that returns:\n\n- 1 if x is positive.\n- -1 if x is negative.\n- 0 if x is equal to 0.\n\nYou are given an integer array nums. Let product be the product of all values in the array nums.\n\nReturn signFunc(product).\n\nExample 1:\n\nInput: nums = [-1,-2,-3,-4,3,2,1]\nOutput: 1\nExplanation: The product of all values in the array is 144, and signFunc(144) = 1\n\nExample 2:\n\nInput: nums = [1,5,0,2,-3]\nOutput: 0\nExplanation: The product of all values in the array is 0, and signFunc(0) = 0\n\nExample 3:\n\nInput: nums = [-1,1,-1,1,-1]\nOutput: -1\nExplanation: The product of all values in the array is -1, and signFunc(-1) = -1\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- -100 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1]) == -1\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [0, 0, 0]) == 0\n assert candidate(nums = [-99, -98, -97, -96, -95, -94, -93, -92, -91, -90]) == 1\n assert candidate(nums = [100, -100, 100]) == -1\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [100, -100, 1]) == -1\n assert candidate(nums = [-100, 0, 100]) == 0\n assert candidate(nums = [-1, -2, -3, -4, 3, 2, 1]) == 1\n assert candidate(nums = [100, -100, 100, -100]) == 1\n assert candidate(nums = [-1, -2, -3, -4]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [1, 5, 0, 2, -3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [-1, -2, -3]) == -1\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1]) == 0\n assert candidate(nums = [100, -50, 25, -10, 5]) == 1\n assert candidate(nums = [100, -50, 25, -12.5, 6.25]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 1\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 0\n assert candidate(nums = [-1, 1, 0, -1, 1, 0, -1, 1, 0]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 0, 60, 70, 80, 90]) == 0\n assert candidate(nums = [1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1]) == 0\n assert candidate(nums = [-50, 50, -50, 50, -50, 50, -50, 50, -50, 50]) == -1\n assert candidate(nums = [50, 25, -10, 4, -2, 0.5, 0.2]) == 1\n assert candidate(nums = [-100, 0, 100, -100, 100, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, -6, -7, -8, -9, -10]) == -1\n assert candidate(nums = [-1, -1, -1, -1, -1]) == -1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == -1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 0\n assert candidate(nums = [0, 1, 2, 3]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == -1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == -1\n assert candidate(nums = [100, -50, 25, -12.5, 0.5]) == 1\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0]) == 0\n assert candidate(nums = [100, -100, 50, -50, 25, -25]) == -1\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6]) == -1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 1\n assert candidate(nums = [1, 0, -1, 2, 0, -2, 3, 0, -3, 4, 0, -4]) == 0\n assert candidate(nums = [100, -50, 0, 25, -10]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [99, 98, 97, -96, -95, -94]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0]) == 0\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [99, -99, 98, -98, 97, -97, 96, -96, 95, -95]) == -1\n assert candidate(nums = [-10, 10, -10, 10]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 0, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 1\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1]) == -1\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == -1\n assert candidate(nums = [-10, -20, -30, -40, -50]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]) == 0\n assert candidate(nums = [100, -50, 20, -10, 5]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -16]) == -1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == -1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(nums = [-1, 0, 1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [100, -100, 100, -100, 100]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == -1\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, 0]) == 0\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100]) == 1\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 1\n assert candidate(nums = [-100, 100, -10, 10, -1, 1]) == -1\n", "comparison": "exact"}, "public_tests": ["[-1,-2,-3,-4,3,2,1]", "[1,5,0,2,-3]", "[-1,1,-1,1,-1]"], "hints": ["If there is a 0 in the array the answer is 0", "To avoid overflow make all the negative numbers -1 and all positive numbers 1 and calculate the prod"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().arraySign", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:49+00:00", "tests_total": 96, "tests_dropped": 9, "flags": [], "topic_tags": ["array", "math"]}, "language": "javascript", "interface": {"raw_signature": "var arraySign = function(nums) {", "container": null, "callable": "arraySign", "parameters": [{"name": "nums", "type": "number[]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1822, "task_id": "sign-of-the-product-of-an-array", "difficulty": "Easy", "problem_description": "Implement a function signFunc(x) that returns:\n\n- 1 if x is positive.\n- -1 if x is negative.\n- 0 if x is equal to 0.\n\nYou are given an integer array nums. Let product be the product of all values in the array nums.\n\nReturn signFunc(product).\n\nExample 1:\n\nInput: nums = [-1,-2,-3,-4,3,2,1]\nOutput: 1\nExplanation: The product of all values in the array is 144, and signFunc(144) = 1\n\nExample 2:\n\nInput: nums = [1,5,0,2,-3]\nOutput: 0\nExplanation: The product of all values in the array is 0, and signFunc(0) = 0\n\nExample 3:\n\nInput: nums = [-1,1,-1,1,-1]\nOutput: -1\nExplanation: The product of all values in the array is -1, and signFunc(-1) = -1\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- -100 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1]) == -1\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [0, 0, 0]) == 0\n assert candidate(nums = [-99, -98, -97, -96, -95, -94, -93, -92, -91, -90]) == 1\n assert candidate(nums = [100, -100, 100]) == -1\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [100, -100, 1]) == -1\n assert candidate(nums = [-100, 0, 100]) == 0\n assert candidate(nums = [-1, -2, -3, -4, 3, 2, 1]) == 1\n assert candidate(nums = [100, -100, 100, -100]) == 1\n assert candidate(nums = [-1, -2, -3, -4]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [1, 5, 0, 2, -3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [-1, -2, -3]) == -1\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1]) == 0\n assert candidate(nums = [100, -50, 25, -10, 5]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 1\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 0\n assert candidate(nums = [-1, 1, 0, -1, 1, 0, -1, 1, 0]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 0, 60, 70, 80, 90]) == 0\n assert candidate(nums = [1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1]) == 0\n assert candidate(nums = [-50, 50, -50, 50, -50, 50, -50, 50, -50, 50]) == -1\n assert candidate(nums = [-100, 0, 100, -100, 100, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, -6, -7, -8, -9, -10]) == -1\n assert candidate(nums = [-1, -1, -1, -1, -1]) == -1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == -1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 0\n assert candidate(nums = [0, 1, 2, 3]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == -1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == -1\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0]) == 0\n assert candidate(nums = [100, -100, 50, -50, 25, -25]) == -1\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6]) == -1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 1\n assert candidate(nums = [1, 0, -1, 2, 0, -2, 3, 0, -3, 4, 0, -4]) == 0\n assert candidate(nums = [100, -50, 0, 25, -10]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [99, 98, 97, -96, -95, -94]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0]) == 0\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [99, -99, 98, -98, 97, -97, 96, -96, 95, -95]) == -1\n assert candidate(nums = [-10, 10, -10, 10]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 0, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 1\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1]) == -1\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == -1\n assert candidate(nums = [-10, -20, -30, -40, -50]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]) == 0\n assert candidate(nums = [100, -50, 20, -10, 5]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -16]) == -1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == -1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(nums = [-1, 0, 1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [100, -100, 100, -100, 100]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == -1\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, 0]) == 0\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100]) == 1\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 1\n assert candidate(nums = [-100, 100, -10, 10, -1, 1]) == -1\n", "comparison": "exact"}, "public_tests": ["[-1,-2,-3,-4,3,2,1]", "[1,5,0,2,-3]", "[-1,1,-1,1,-1]"], "hints": ["If there is a 0 in the array the answer is 0", "To avoid overflow make all the negative numbers -1 and all positive numbers 1 and calculate the prod"], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().arraySign", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:49+00:00", "tests_total": 96, "tests_dropped": 12, "flags": [], "topic_tags": ["array", "math"]}, "language": "javascript", "interface": {"raw_signature": "var arraySign = function(nums) {", "container": null, "callable": "arraySign", "parameters": [{"name": "nums", "type": "number[]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1823, "task_id": "find-the-winner-of-the-circular-game", "difficulty": "Medium", "problem_description": "There are n friends that are playing a game. The friends are sitting in a circle and are numbered from 1 to n in clockwise order. More formally, moving clockwise from the i^th friend brings you to the (i+1)^th friend for 1 <= i < n, and moving clockwise from the n^th friend brings you to the 1^st friend.\n\nThe rules of the game are as follows:\n\n1. Start at the 1^st friend.\n2. Count the next k friends in the clockwise direction including the friend you started at. The counting wraps around the circle and may count some friends more than once.\n3. The last friend you counted leaves the circle and loses the game.\n4. If there is still more than one friend in the circle, go back to step 2 starting from the friend immediately clockwise of the friend who just lost and repeat.\n5. Else, the last friend in the circle wins the game.\n\nGiven the number of friends, n, and an integer k, return the winner of the game.\n\nExample 1:\n\nInput: n = 5, k = 2\nOutput: 3\nExplanation: Here are the steps of the game:\n1) Start at friend 1.\n2) Count 2 friends clockwise, which are friends 1 and 2.\n3) Friend 2 leaves the circle. Next start is friend 3.\n4) Count 2 friends clockwise, which are friends 3 and 4.\n5) Friend 4 leaves the circle. Next start is friend 5.\n6) Count 2 friends clockwise, which are friends 5 and 1.\n7) Friend 1 leaves the circle. Next start is friend 3.\n8) Count 2 friends clockwise, which are friends 3 and 5.\n9) Friend 5 leaves the circle. Only friend 3 is left, so they are the winner.\n\nExample 2:\n\nInput: n = 6, k = 5\nOutput: 1\nExplanation: The friends leave in this order: 5, 4, 6, 2, 3. The winner is friend 1.\n\nConstraints:\n\n- 1 <= k <= n <= 500\n\nFollow up:\n\nCould you solve this problem in linear time with constant space?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,k = 1) == 3\n assert candidate(n = 3,k = 3) == 2\n assert candidate(n = 5,k = 2) == 3\n assert candidate(n = 7,k = 3) == 4\n assert candidate(n = 7,k = 1) == 7\n assert candidate(n = 6,k = 5) == 1\n assert candidate(n = 7,k = 7) == 5\n assert candidate(n = 1,k = 1) == 1\n assert candidate(n = 4,k = 4) == 2\n assert candidate(n = 10,k = 4) == 5\n assert candidate(n = 10,k = 3) == 4\n assert candidate(n = 250,k = 125) == 173\n assert candidate(n = 300,k = 150) == 152\n assert candidate(n = 250,k = 150) == 76\n assert candidate(n = 200,k = 100) == 189\n assert candidate(n = 150,k = 50) == 138\n assert candidate(n = 300,k = 300) == 265\n assert candidate(n = 450,k = 450) == 87\n assert candidate(n = 123,k = 123) == 94\n assert candidate(n = 499,k = 250) == 134\n assert candidate(n = 300,k = 200) == 139\n assert candidate(n = 100,k = 13) == 70\n assert candidate(n = 500,k = 1) == 500\n assert candidate(n = 37,k = 37) == 16\n assert candidate(n = 500,k = 250) == 384\n assert candidate(n = 20,k = 19) == 11\n assert candidate(n = 200,k = 199) == 163\n assert candidate(n = 100,k = 99) == 88\n assert candidate(n = 30,k = 15) == 4\n assert candidate(n = 50,k = 7) == 1\n assert candidate(n = 30,k = 29) == 25\n assert candidate(n = 50,k = 2) == 37\n assert candidate(n = 250,k = 89) == 225\n assert candidate(n = 250,k = 3) == 41\n assert candidate(n = 50,k = 10) == 36\n assert candidate(n = 100,k = 37) == 45\n assert candidate(n = 40,k = 7) == 24\n assert candidate(n = 45,k = 23) == 36\n assert candidate(n = 45,k = 19) == 14\n assert candidate(n = 100,k = 50) == 95\n assert candidate(n = 123,k = 45) == 116\n assert candidate(n = 45,k = 13) == 36\n assert candidate(n = 500,k = 2) == 489\n assert candidate(n = 499,k = 300) == 36\n assert candidate(n = 200,k = 1) == 200\n assert candidate(n = 300,k = 299) == 145\n assert candidate(n = 400,k = 399) == 30\n assert candidate(n = 125,k = 124) == 31\n assert candidate(n = 150,k = 75) == 125\n assert candidate(n = 20,k = 7) == 3\n assert candidate(n = 350,k = 7) == 211\n assert candidate(n = 150,k = 2) == 45\n assert candidate(n = 123,k = 57) == 77\n assert candidate(n = 150,k = 41) == 79\n assert candidate(n = 200,k = 67) == 163\n assert candidate(n = 499,k = 499) == 122\n assert candidate(n = 500,k = 499) == 121\n assert candidate(n = 500,k = 500) == 69\n assert candidate(n = 400,k = 100) == 313\n assert candidate(n = 499,k = 5) == 327\n assert candidate(n = 200,k = 50) == 23\n assert candidate(n = 20,k = 5) == 7\n assert candidate(n = 250,k = 249) == 204\n assert candidate(n = 40,k = 13) == 14\n assert candidate(n = 50,k = 11) == 10\n assert candidate(n = 450,k = 3) == 286\n assert candidate(n = 450,k = 449) == 143\n assert candidate(n = 50,k = 13) == 5\n assert candidate(n = 15,k = 11) == 12\n assert candidate(n = 37,k = 13) == 14\n assert candidate(n = 15,k = 7) == 5\n assert candidate(n = 30,k = 11) == 28\n assert candidate(n = 300,k = 100) == 59\n assert candidate(n = 40,k = 19) == 6\n assert candidate(n = 120,k = 1) == 120\n assert candidate(n = 299,k = 299) == 146\n assert candidate(n = 50,k = 17) == 8\n assert candidate(n = 150,k = 1) == 150\n assert candidate(n = 250,k = 100) == 23\n assert candidate(n = 45,k = 20) == 29\n assert candidate(n = 373,k = 186) == 14\n assert candidate(n = 499,k = 2) == 487\n assert candidate(n = 50,k = 25) == 5\n", "comparison": "exact"}, "public_tests": ["5\n2", "6\n5"], "hints": ["Simulate the process.", "Maintain in a circular list the people who are still in the circle and the current person you are standing at.", "In each turn, count k people and remove the last person from the list."], "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().findTheWinner", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:51+00:00", "tests_total": 83, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "math", "recursion", "queue", "simulation"]}, "language": "javascript", "interface": {"raw_signature": "var findTheWinner = function(n, k) {", "container": null, "callable": "findTheWinner", "parameters": [{"name": "n", "type": "number"}, {"name": "k", "type": "number"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1824, "task_id": "minimum-sideway-jumps", "difficulty": "Medium", "problem_description": "There is a 3 lane road of length n that consists of n + 1 points labeled from 0 to n. A frog starts at point 0 in the second lane and wants to jump to point n. However, there could be obstacles along the way.\n\nYou are given an array obstacles of length n + 1 where each obstacles[i] (ranging from 0 to 3) describes an obstacle on the lane obstacles[i] at point i. If obstacles[i] == 0, there are no obstacles at point i. There will be at most one obstacle in the 3 lanes at each point.\n\n- For example, if obstacles[2] == 1, then there is an obstacle on lane 1 at point 2.\n\nThe frog can only travel from point i to point i + 1 on the same lane if there is not an obstacle on the lane at point i + 1. To avoid obstacles, the frog can also perform a side jump to jump to another lane (even if they are not adjacent) at the same point if there is no obstacle on the new lane.\n\n- For example, the frog can jump from lane 3 at point 3 to lane 1 at point 3.\n\nReturn the minimum number of side jumps the frog needs to reach any lane at point n starting from lane 2 at point 0.\n\nNote: There will be no obstacles on points 0 and n.\n\nExample 1:\n\nInput: obstacles = [0,1,2,3,0]\nOutput: 2\nExplanation: The optimal solution is shown by the arrows above. There are 2 side jumps (red arrows).\nNote that the frog can jump over obstacles only when making side jumps (as shown at point 2).\n\nExample 2:\n\nInput: obstacles = [0,1,1,3,3,0]\nOutput: 0\nExplanation: There are no obstacles on lane 2. No side jumps are required.\n\nExample 3:\n\nInput: obstacles = [0,2,1,0,3,0]\nOutput: 2\nExplanation: The optimal solution is shown by the arrows above. There are 2 side jumps.\n\nConstraints:\n\n- obstacles.length == n + 1\n- 1 <= n <= 5 * 10^5\n- 0 <= obstacles[i] <= 3\n- obstacles[0] == obstacles[n] == 0\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(obstacles = [0, 1, 0, 0, 2, 0, 0, 3, 0, 0]) == 1\n assert candidate(obstacles = [0, 0, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 3, 2, 1, 0, 3, 2, 1, 0]) == 4\n assert candidate(obstacles = [0, 0, 1, 0, 0, 2, 0, 0, 3, 0]) == 1\n assert candidate(obstacles = [0, 1, 3, 2, 3, 1, 0, 0, 0, 0]) == 2\n assert candidate(obstacles = [0, 3, 0, 0, 2, 0, 0, 1, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 0, 0]) == 5\n assert candidate(obstacles = [0, 2, 1, 0, 3, 0]) == 2\n assert candidate(obstacles = [0, 1, 2, 0, 2, 1, 0, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 2, 0, 0, 0, 3, 0, 0, 1, 0]) == 2\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 0]) == 1\n assert candidate(obstacles = [0, 1, 1, 3, 3, 0]) == 0\n assert candidate(obstacles = [0, 3, 2, 1, 3, 0]) == 3\n assert candidate(obstacles = [0, 0, 1, 2, 3, 0]) == 2\n assert candidate(obstacles = [0, 3, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 2, 0, 2, 0, 2, 0]) == 1\n assert candidate(obstacles = [0, 3, 0, 3, 0, 3, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 3, 0]) == 2\n assert candidate(obstacles = [0, 1, 0, 0, 2, 0]) == 1\n assert candidate(obstacles = [0, 2, 3, 2, 1, 2, 3, 0]) == 3\n assert candidate(obstacles = [0, 3, 2, 1, 0, 0]) == 2\n assert candidate(obstacles = [0, 1, 2, 0, 3, 0]) == 2\n assert candidate(obstacles = [0, 2, 3, 1, 0, 0]) == 2\n assert candidate(obstacles = [0, 2, 2, 2, 2, 0]) == 1\n assert candidate(obstacles = [0, 3, 2, 1, 3, 2, 1, 0]) == 5\n assert candidate(obstacles = [0, 3, 0, 1, 2, 0, 0, 0, 0, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 16\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 0]) == 11\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 0]) == 12\n assert candidate(obstacles = [0, 3, 3, 3, 3, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0]) == 2\n assert candidate(obstacles = [0, 2, 3, 1, 0, 2, 3, 1, 0, 2, 3, 1, 0, 2, 3, 1, 0, 2, 3, 1, 0]) == 10\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 8\n assert candidate(obstacles = [0, 1, 1, 1, 1, 0, 2, 2, 2, 2, 0, 3, 3, 3, 3, 0, 1, 1, 1, 1, 0]) == 2\n assert candidate(obstacles = [0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0]) == 2\n assert candidate(obstacles = [0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 20\n assert candidate(obstacles = [0, 1, 2, 0, 3, 0, 1, 2, 0, 3, 0, 1, 2, 0, 3, 0, 1, 2, 0]) == 7\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == 4\n assert candidate(obstacles = [0, 1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 0]) == 5\n assert candidate(obstacles = [0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0]) == 10\n assert candidate(obstacles = [0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0]) == 2\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == 3\n assert candidate(obstacles = [0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]) == 1\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 10\n assert candidate(obstacles = [0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0]) == 0\n assert candidate(obstacles = [0, 3, 2, 0, 1, 0, 3, 2, 0, 1, 0, 3, 0]) == 4\n assert candidate(obstacles = [0, 1, 0, 0, 2, 0, 3, 0, 0, 1, 0, 0, 0, 3, 0, 2, 0]) == 3\n assert candidate(obstacles = [0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0]) == 2\n assert candidate(obstacles = [0, 3, 3, 2, 2, 1, 1, 3, 3, 2, 2, 1, 1, 0]) == 5\n assert candidate(obstacles = [0, 1, 3, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 10\n assert candidate(obstacles = [0, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0]) == 10\n assert candidate(obstacles = [0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0]) == 4\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 13\n assert candidate(obstacles = [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 12\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0]) == 7\n assert candidate(obstacles = [0, 3, 2, 1, 0, 2, 1, 0, 3, 2, 1, 0, 2, 1, 3, 0]) == 5\n assert candidate(obstacles = [0, 1, 3, 2, 3, 1, 2, 3, 0, 1, 2, 3, 0]) == 6\n assert candidate(obstacles = [0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0]) == 3\n assert candidate(obstacles = [0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 30\n assert candidate(obstacles = [0, 2, 1, 3, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 26\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 11\n assert candidate(obstacles = [0, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 3, 1, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 25\n assert candidate(obstacles = [0, 2, 2, 0, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1, 0]) == 5\n assert candidate(obstacles = [0, 3, 0, 2, 3, 1, 0, 2, 3, 1, 0, 2, 3, 1, 0]) == 6\n assert candidate(obstacles = [0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 0]) == 7\n assert candidate(obstacles = [0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0]) == 8\n assert candidate(obstacles = [0, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 8\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == 6\n assert candidate(obstacles = [0, 1, 3, 2, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 18\n assert candidate(obstacles = [0, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 0, 3, 3, 3, 3, 3, 0]) == 1\n assert candidate(obstacles = [0, 1, 2, 0, 3, 0, 1, 2, 0, 3, 0, 1, 0]) == 4\n assert candidate(obstacles = [0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0]) == 2\n assert candidate(obstacles = [0, 3, 2, 1, 0, 2, 1, 0, 3, 1, 0, 2, 1, 0, 3, 1, 0, 2, 1, 0]) == 6\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 19\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 31\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 0, 3, 2, 1, 0, 2, 1, 3, 2, 1, 0]) == 11\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 2, 3, 2, 1, 0]) == 5\n assert candidate(obstacles = [0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 23\n assert candidate(obstacles = [0, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 0]) == 1\n assert candidate(obstacles = [0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0]) == 3\n assert candidate(obstacles = [0, 3, 2, 1, 2, 3, 1, 2, 3, 1, 0]) == 7\n assert candidate(obstacles = [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0]) == 3\n assert candidate(obstacles = [0, 3, 3, 3, 3, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]) == 1\n assert candidate(obstacles = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 0\n assert candidate(obstacles = [0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0]) == 3\n assert candidate(obstacles = [0, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 0]) == 12\n assert candidate(obstacles = [0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0]) == 3\n assert candidate(obstacles = [0, 1, 2, 3, 0, 2, 1, 3, 0, 1, 2, 3, 0]) == 6\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 11\n assert candidate(obstacles = [0, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 17\n assert candidate(obstacles = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == 7\n assert candidate(obstacles = [0, 3, 0, 1, 0, 3, 0, 1, 0, 3, 0, 1, 0, 3, 0]) == 0\n assert candidate(obstacles = [0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0]) == 3\n assert candidate(obstacles = [0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 2, 1, 0]) == 2\n assert candidate(obstacles = [0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 17\n assert candidate(obstacles = [0, 1, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 6\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0]) == 2\n assert candidate(obstacles = [0, 2, 3, 2, 1, 3, 2, 1, 3, 2, 0]) == 7\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0]) == 4\n assert candidate(obstacles = [0, 3, 2, 3, 1, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 9\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 0]) == 9\n assert candidate(obstacles = [0, 3, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]) == 2\n assert candidate(obstacles = [0, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(obstacles = [0, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 11\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 9\n assert candidate(obstacles = [0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0]) == 0\n", "comparison": "exact"}, "public_tests": ["[0,1,2,3,0]", "[0,1,1,3,3,0]", "[0,2,1,0,3,0]"], "hints": ["At a given point, there are only 3 possible states for where the frog can be.", "Check all the ways to move from one point to the next and update the minimum side jumps for each lane."], "metadata": {"canonical_parameter_names": ["obstacles"], "leetcode_dataset_entry_point": "Solution().minSideJumps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:54+00:00", "tests_total": 132, "tests_dropped": 11, "flags": ["has_images"], "topic_tags": ["array", "dynamic-programming", "greedy"]}, "language": "javascript", "interface": {"raw_signature": "var minSideJumps = function(obstacles) {", "container": null, "callable": "minSideJumps", "parameters": [{"name": "obstacles", "type": "number[]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 1827, "task_id": "minimum-operations-to-make-the-array-increasing", "difficulty": "Easy", "problem_description": "You are given an integer array nums (0-indexed). In one operation, you can choose an element of the array and increment it by 1.\n\n- For example, if nums = [1,2,3], you can choose to increment nums[1] to make nums = [1,3,3].\n\nReturn the minimum number of operations needed to make nums strictly increasing.\n\nAn array nums is strictly increasing if nums[i] < nums[i+1] for all 0 <= i < nums.length - 1. An array of length 1 is trivially strictly increasing.\n\nExample 1:\n\nInput: nums = [1,1,1]\nOutput: 3\nExplanation: You can do the following operations:\n1) Increment nums[2], so nums becomes [1,1,2].\n2) Increment nums[1], so nums becomes [1,2,2].\n3) Increment nums[2], so nums becomes [1,2,3].\n\nExample 2:\n\nInput: nums = [1,5,2,4,1]\nOutput: 14\n\nExample 3:\n\nInput: nums = [8]\nOutput: 0\n\nConstraints:\n\n- 1 <= nums.length <= 5000\n- 1 <= nums[i] <= 10^4\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [10000, 1, 1, 1, 1]) == 40006\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 25\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == 109\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5]) == 7\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 25\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 16\n assert candidate(nums = [8]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 1, 1]) == 3\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000]) == 10\n assert candidate(nums = [10000, 10000, 10000, 10000]) == 6\n assert candidate(nums = [1, 5, 2, 4, 1]) == 14\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10]) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 400\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 66\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 10\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 380\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4095\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 45045\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 380\n assert candidate(nums = [1, 100, 50, 200, 100, 300, 150, 400, 200, 500]) == 504\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 190\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 0\n assert candidate(nums = [1, 5, 10, 15, 20, 25, 20, 25, 30, 35]) == 8\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 90\n assert candidate(nums = [5, 6, 6, 10, 8, 11, 11, 11]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [100, 200, 300, 200, 100, 200, 300, 400, 500]) == 410\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15]) == 273\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == 380\n assert candidate(nums = [10, 9, 10, 8, 10, 7, 10, 6, 10, 5, 10, 4, 10, 3, 10, 2, 10, 1, 10]) == 216\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 870\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 300\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 6215\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 225\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 0\n assert candidate(nums = [59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 1305\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 21, 20, 22, 21, 23, 22, 24, 23, 25]) == 35\n assert candidate(nums = [10000, 1000, 100, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 189064\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21]) == 18\n assert candidate(nums = [5000, 4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990, 4989, 4988, 4987, 4986, 4985, 4984, 4983, 4982, 4981, 4980, 4979, 4978, 4977, 4976, 4975, 4974, 4973, 4972, 4971, 4970]) == 930\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 180\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15]) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 375\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 480\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 100\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 25\n assert candidate(nums = [5, 6, 6, 8, 8, 9, 9, 10, 10, 10, 11]) == 18\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 3, 2, 1]) == 930\n assert candidate(nums = [5, 3, 5, 3, 5, 3, 5, 3, 5, 3]) == 55\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 172\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 65\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4]) == 189\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5]) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 36\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 81\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 80\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9]) == 486\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990]) == 110\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 24\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 5055\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 45045\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 4000, 3000, 2000, 1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 1, 1, 1, 1, 1, 1, 1]) == 89209\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 280\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 260\n assert candidate(nums = [2, 3, 3, 5, 5, 5, 6, 7, 8, 8, 9, 9, 9]) == 25\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11]) == 2\n assert candidate(nums = [1, 2, 10, 11, 10, 12, 11, 13, 12, 14]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 464\n assert candidate(nums = [10, 9, 10, 9, 10, 9, 10, 9, 10, 9]) == 50\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7]) == 133\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 212\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 189\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 7, 8, 9, 10]) == 17\n assert candidate(nums = [100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50]) == 690\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 99\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1128\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 22935\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 4140\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 171\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 14\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 100, 100, 100]) == 7278\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 72\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [100, 100, 100, 100, 100, 101, 101, 101, 101, 101, 102, 102, 102, 102, 102, 103, 103, 103, 103, 103, 104, 104, 104, 104, 104, 105, 105, 105, 105, 105]) == 360\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 155\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 75\n assert candidate(nums = [1, 1, 10, 10, 100, 100, 1000, 1000, 10000, 10000]) == 5\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6]) == 36\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 280\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 45\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == 40\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 496\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 1325\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 99\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 180\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 190\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 495\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 105\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 252\n", "comparison": "exact"}, "public_tests": ["[1,1,1]", "[1,5,2,4,1]", "[8]"], "hints": ["nums[i+1] must be at least equal to nums[i] + 1.", "Think greedily. You don't have to increase nums[i+1] beyond nums[i]+1.", "Iterate on i and set nums[i] = max(nums[i-1]+1, nums[i]) ."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:31:58+00:00", "tests_total": 118, "tests_dropped": 5, "flags": [], "topic_tags": ["array", "greedy"]}, "language": "javascript", "interface": {"raw_signature": "var minOperations = function(nums) {", "container": null, "callable": "minOperations", "parameters": [{"name": "nums", "type": "number[]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} @@ -315,13 +314,13 @@ {"question_id": 2088, "task_id": "count-fertile-pyramids-in-a-land", "difficulty": "Hard", "problem_description": "A farmer has a rectangular grid of land with m rows and n columns that can be divided into unit cells. Each cell is either fertile (represented by a 1) or barren (represented by a 0). All cells outside the grid are considered barren.\n\nA pyramidal plot of land can be defined as a set of cells with the following criteria:\n\n1. The number of cells in the set has to be greater than 1 and all cells must be fertile.\n2. The apex of a pyramid is the topmost cell of the pyramid. The height of a pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r <= i <= r + h - 1 and c - (i - r) <= j <= c + (i - r).\n\nAn inverse pyramidal plot of land can be defined as a set of cells with similar criteria:\n\n1. The number of cells in the set has to be greater than 1 and all cells must be fertile.\n2. The apex of an inverse pyramid is the bottommost cell of the inverse pyramid. The height of an inverse pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r - h + 1 <= i <= r and c - (r - i) <= j <= c + (r - i).\n\nSome examples of valid and invalid pyramidal (and inverse pyramidal) plots are shown below. Black cells indicate fertile cells.\n\nGiven a 0-indexed m x n binary matrix grid representing the farmland, return the total number of pyramidal and inverse pyramidal plots that can be found in grid.\n\nExample 1:\n\nInput: grid = [[0,1,1,0],[1,1,1,1]]\nOutput: 2\nExplanation: The 2 possible pyramidal plots are shown in blue and red respectively.\nThere are no inverse pyramidal plots in this grid.\nHence total number of pyramidal and inverse pyramidal plots is 2 + 0 = 2.\n\nExample 2:\n\nInput: grid = [[1,1,1],[1,1,1]]\nOutput: 2\nExplanation: The pyramidal plot is shown in blue, and the inverse pyramidal plot is shown in red.\nHence the total number of plots is 1 + 1 = 2.\n\nExample 3:\n\nInput: grid = [[1,1,1,1,0],[1,1,1,1,1],[1,1,1,1,1],[0,1,0,0,1]]\nOutput: 13\nExplanation: There are 7 pyramidal plots, 3 of which are shown in the 2nd and 3rd figures.\nThere are 6 inverse pyramidal plots, 2 of which are shown in the last figure.\nThe total number of plots is 7 + 6 = 13.\n\nConstraints:\n\n- m == grid.length\n- n == grid[i].length\n- 1 <= m, n <= 1000\n- 1 <= m * n <= 10^5\n- grid[i][j] is either 0 or 1.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 0], [1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 0, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 0, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 30\n assert candidate(grid = [[1, 1, 0, 1], [1, 1, 1, 1], [0, 1, 1, 0]]) == 3\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 14\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 8\n assert candidate(grid = [[1, 1, 1], [1, 1, 1]]) == 2\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [0, 1, 0, 0, 1]]) == 13\n assert candidate(grid = [[0, 1, 1, 0, 0, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1]]) == 4\n assert candidate(grid = [[1, 1], [1, 1]]) == 0\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 15\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0]]) == 32\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0]]) == 54\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 120\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0]]) == 24\n assert candidate(grid = [[1, 1, 1, 0, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1]]) == 34\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 32\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 8\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 0, 1, 1, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 36\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 1, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 24\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 41\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0]]) == 88\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 80\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0]]) == 16\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 1140\n assert candidate(grid = [[0, 0, 1, 0, 0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0, 0, 0]]) == 75\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1]]) == 12\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 8\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]]) == 50\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 128\n assert candidate(grid = [[1, 0, 1, 0, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0]]) == 19\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 18\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]]) == 40\n assert candidate(grid = [[1, 1, 1, 0, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 14\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 0, 1, 1, 0, 1]]) == 14\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 100\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0]]) == 177\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 1, 0, 0, 0, 0, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 8\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 24\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 53\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 32\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 200\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 54\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0]]) == 112\n", "comparison": "exact"}, "public_tests": ["[[0,1,1,0],[1,1,1,1]]", "[[1,1,1],[1,1,1]]", "[[1,1,1,1,0],[1,1,1,1,1],[1,1,1,1,1],[0,1,0,0,1]]"], "hints": ["Think about how dynamic programming can help solve the problem.", "For any fixed cell (r, c), can you calculate the maximum height of the pyramid for which it is the apex? Let us denote this value as dp[r][c].", "How will the values at dp[r+1][c-1] and dp[r+1][c+1] help in determining the value at dp[r][c]?", "For the cell (r, c), is there a relation between the number of pyramids for which it serves as the apex and dp[r][c]? How does it help in calculating the answer?"], "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().countPyramids", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:38+00:00", "tests_total": 74, "tests_dropped": 0, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "dynamic-programming", "matrix"]}, "language": "javascript", "interface": {"raw_signature": "var countPyramids = function(grid) {", "container": null, "callable": "countPyramids", "parameters": [{"name": "grid", "type": "number[][]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2089, "task_id": "find-target-indices-after-sorting-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums and a target element target.\n\nA target index is an index i such that nums[i] == target.\n\nReturn a list of the target indices of nums after sorting nums in non-decreasing order. If there are no target indices, return an empty list. The returned list must be sorted in increasing order.\n\nExample 1:\n\nInput: nums = [1,2,5,2,3], target = 2\nOutput: [1,2]\nExplanation: After sorting, nums is [1,2,2,3,5].\nThe indices where nums[i] == 2 are 1 and 2.\n\nExample 2:\n\nInput: nums = [1,2,5,2,3], target = 3\nOutput: [3]\nExplanation: After sorting, nums is [1,2,2,3,5].\nThe index where nums[i] == 3 is 3.\n\nExample 3:\n\nInput: nums = [1,2,5,2,3], target = 5\nOutput: [4]\nExplanation: After sorting, nums is [1,2,2,3,5].\nThe index where nums[i] == 5 is 4.\n\nConstraints:\n\n- 1 <= nums.length <= 100\n- 1 <= nums[i], target <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 99, 98, 97, 96],target = 98) == [2]\n assert candidate(nums = [10, 20, 30, 40, 50],target = 50) == [4]\n assert candidate(nums = [7, 7, 7, 7, 7],target = 8) == []\n assert candidate(nums = [10, 20, 30, 40, 50],target = 25) == []\n assert candidate(nums = [50, 40, 30, 20, 10],target = 15) == []\n assert candidate(nums = [100, 100, 100],target = 100) == [0, 1, 2]\n assert candidate(nums = [1, 2, 5, 2, 3],target = 3) == [3]\n assert candidate(nums = [2, 4, 6, 8, 10],target = 2) == [0]\n assert candidate(nums = [5, 5, 5, 5, 5],target = 5) == [0, 1, 2, 3, 4]\n assert candidate(nums = [1, 1, 1, 1, 1],target = 1) == [0, 1, 2, 3, 4]\n assert candidate(nums = [5, 4, 3, 2, 1],target = 3) == [2]\n assert candidate(nums = [1, 3, 5, 7, 9],target = 2) == []\n assert candidate(nums = [1, 2, 2, 2, 3, 4],target = 2) == [1, 2, 3]\n assert candidate(nums = [1, 2, 5, 2, 3],target = 2) == [1, 2]\n assert candidate(nums = [50, 50, 50, 50, 50],target = 50) == [0, 1, 2, 3, 4]\n assert candidate(nums = [5, 5, 5, 5, 5],target = 6) == []\n assert candidate(nums = [1, 3, 5, 7, 9],target = 10) == []\n assert candidate(nums = [100, 1, 100, 1, 100],target = 1) == [0, 1]\n assert candidate(nums = [1, 2, 5, 2, 3],target = 5) == [4]\n assert candidate(nums = [1, 1, 1, 1, 1],target = 2) == []\n assert candidate(nums = [1, 3, 5, 7, 9],target = 4) == []\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = 4) == [6, 7]\n assert candidate(nums = [5, 4, 3, 2, 1],target = 3) == [2]\n assert candidate(nums = [90, 80, 70, 60, 50, 40, 30, 20, 10],target = 45) == []\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 50) == [4]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],target = 95) == [5]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10],target = 7) == [6]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],target = 5) == [4]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],target = 27) == [8]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],target = 4) == [3]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],target = 5) == [4]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],target = 35) == [6]\n assert candidate(nums = [100, 100, 99, 99, 98, 98, 97, 97],target = 99) == [4, 5]\n assert candidate(nums = [45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31],target = 37) == [6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 1) == [0]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 8) == [3]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 10) == []\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 5) == [4]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],target = 20) == []\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1],target = 4) == [3]\n assert candidate(nums = [42, 24, 36, 18, 54, 30, 48, 27, 60, 39],target = 30) == [3]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1],target = 5) == [4]\n assert candidate(nums = [100, 50, 30, 70, 20],target = 30) == [1]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 50) == [4]\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],target = 8) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [42, 23, 37, 23, 42, 37],target = 37) == [2, 3]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],target = 4) == [7, 8, 9, 10]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7],target = 15) == [8]\n assert candidate(nums = [100, 99, 98, 97, 96, 95],target = 98) == [3]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],target = 55) == [5]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = 15) == [7]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 10) == [9]\n assert candidate(nums = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1],target = 2) == [5, 6, 7, 8, 9]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 55) == []\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 1) == [0]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],target = 35) == [4]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],target = 3) == [6, 7, 8]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 20) == [9]\n assert candidate(nums = [100, 99, 98, 97, 96],target = 97) == [1]\n assert candidate(nums = [8, 6, 6, 6, 8, 6, 8, 6, 8, 6, 6, 6, 6, 6],target = 6) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [42, 27, 89, 10, 56, 23, 50, 78, 34, 67],target = 50) == [5]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = 8) == []\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],target = 10) == [18, 19]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 40) == [3]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 11) == []\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],target = 5) == [4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10) == [9]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],target = 13) == [12]\n assert candidate(nums = [50, 20, 30, 40, 10],target = 30) == [2]\n assert candidate(nums = [100, 1, 50, 20, 30, 60, 40],target = 30) == [2]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 6) == [5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == [14]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],target = 10) == [9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 15) == [14]\n assert candidate(nums = [50, 50, 50, 50, 50, 50],target = 50) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 8) == [7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 11) == []\n assert candidate(nums = [10, 20, 30, 40, 50],target = 20) == [1]\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],target = 20) == [5, 6, 7, 8, 9]\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == [5]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = 17) == []\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],target = 95) == [4]\n assert candidate(nums = [50, 20, 30, 10, 40],target = 30) == [2]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],target = 50) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 6) == []\n assert candidate(nums = [3, 1, 2, 5, 4, 2, 3, 3, 5, 1],target = 3) == [4, 5, 6]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],target = 50) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1],target = 2) == []\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = 6) == []\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = 18) == [8]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 5) == [4]\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100],target = 1) == [0, 1, 2]\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3],target = 2) == [3, 4, 5]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 5) == [4]\n assert candidate(nums = [50, 20, 30, 40, 10],target = 20) == [1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 10) == []\n assert candidate(nums = [50, 20, 30, 40, 10, 60, 70, 80, 90, 100],target = 40) == [3]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 10) == [9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 21) == []\n assert candidate(nums = [3, 1, 2, 5, 4],target = 4) == [3]\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == [8]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10],target = 15) == [5]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 55) == []\n assert candidate(nums = [10, 20, 10, 20, 10, 20],target = 10) == [0, 1, 2]\n assert candidate(nums = [50, 40, 30, 20, 10],target = 30) == [2]\n assert candidate(nums = [50, 40, 30, 20, 10],target = 20) == [1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == [14]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 6) == [5]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],target = 25) == [12]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 5) == [4]\n assert candidate(nums = [3, 1, 2, 4, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 3) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(nums = [42, 37, 58, 54, 19, 91, 49, 100, 65, 28, 74, 99, 96, 33, 80, 78, 60, 82, 97, 71],target = 74) == [11]\n", "comparison": "exact"}, "public_tests": ["[1,2,5,2,3]\n2", "[1,2,5,2,3]\n3", "[1,2,5,2,3]\n5"], "hints": ["Try \"sorting\" the array first.", "Now find all indices in the array whose values are equal to target."], "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().targetIndices", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:40+00:00", "tests_total": 118, "tests_dropped": 3, "flags": [], "topic_tags": ["array", "binary-search", "sorting"]}, "language": "javascript", "interface": {"raw_signature": "var targetIndices = function(nums, target) {", "container": null, "callable": "targetIndices", "parameters": [{"name": "nums", "type": "number[]"}, {"name": "target", "type": "number"}], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2090, "task_id": "k-radius-subarray-averages", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums of n integers, and an integer k.\n\nThe k-radius average for a subarray of nums centered at some index i with the radius k is the average of all elements in nums between the indices i - k and i + k (inclusive). If there are less than k elements before or after the index i, then the k-radius average is -1.\n\nBuild and return an array avgs of length n where avgs[i] is the k-radius average for the subarray centered at index i.\n\nThe average of x elements is the sum of the x elements divided by x, using integer division. The integer division truncates toward zero, which means losing its fractional part.\n\n- For example, the average of four elements 2, 3, 1, and 5 is (2 + 3 + 1 + 5) / 4 = 11 / 4 = 2.75, which truncates to 2.\n\nExample 1:\n\nInput: nums = [7,4,3,9,1,8,5,2,6], k = 3\nOutput: [-1,-1,-1,5,4,4,-1,-1,-1]\nExplanation:\n- avg[0], avg[1], and avg[2] are -1 because there are less than k elements before each index.\n- The sum of the subarray centered at index 3 with radius 3 is: 7 + 4 + 3 + 9 + 1 + 8 + 5 = 37.\n Using integer division, avg[3] = 37 / 7 = 5.\n- For the subarray centered at index 4, avg[4] = (4 + 3 + 9 + 1 + 8 + 5 + 2) / 7 = 4.\n- For the subarray centered at index 5, avg[5] = (3 + 9 + 1 + 8 + 5 + 2 + 6) / 7 = 4.\n- avg[6], avg[7], and avg[8] are -1 because there are less than k elements after each index.\n\nExample 2:\n\nInput: nums = [100000], k = 0\nOutput: [100000]\nExplanation:\n- The sum of the subarray centered at index 0 with radius 0 is: 100000.\n avg[0] = 100000 / 1 = 100000.\n\nExample 3:\n\nInput: nums = [8], k = 100000\nOutput: [-1]\nExplanation:\n- avg[0] is -1 because there are less than k elements before and after index 0.\n\nConstraints:\n\n- n == nums.length\n- 1 <= n <= 10^5\n- 0 <= nums[i], k <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == [-1, -1, 3, 4, 5, 6, 7, 8, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0],k = 2) == [-1, -1, 0, -1, -1]\n assert candidate(nums = [100000],k = 0) == [100000]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == [-1, -1, -1, -1, 5, 5, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 2) == [-1, -1, 3, 4, 5, 6, 7, -1, -1]\n assert candidate(nums = [8],k = 100000) == [-1]\n assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == [-1, -1, 3, -1, -1]\n assert candidate(nums = [5],k = 0) == [5]\n assert candidate(nums = [5, 5, 5, 5, 5],k = 1) == [-1, 5, 5, 5, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == [-1, -1, -1, -1, 5, 6, -1, -1, -1, -1]\n assert candidate(nums = [7, 4, 3, 9, 1, 8, 5, 2, 6],k = 3) == [-1, -1, -1, 5, 4, 4, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == [-1, 2, 3, 4, -1]\n assert candidate(nums = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],k = 3) == [-1, -1, -1, 102, 103, 104, 105, 106, 107, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 7) == [-1, -1, -1, -1, -1, -1, -1, 8, 9, 10, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 0) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5) == [-1, -1, -1, -1, -1, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 12) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 5) == [-1, -1, -1, -1, -1, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, -1, -1, -1, -1, -1]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 0) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 0) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 3) == [-1, -1, -1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7) == [-1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 3) == [-1, -1, -1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4) == [-1, -1, -1, -1, 5, 4, -1, -1, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 3) == [-1, -1, -1, 2, 1, 1, 1, 2, -1, -1, -1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == [-1, -1, -1, -1, 6, 5, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 2) == [-1, -1, 3, 2, 1, 1, 1, 2, 3, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 7) == [-1, -1, -1, -1, -1, -1, -1, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 3) == [-1, -1, -1, 7, 9, 11, 13, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 4) == [-1, -1, -1, -1, 0, 0, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 2) == [-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 4) == [-1, -1, -1, -1, 5000, 6000, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, -1, -1, -1, -1, -1]\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == [-1, -1, -1, -1, -1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 2) == [-1, -1, 99998, 99997, 99996, 99995, 99994, 99993, -1, -1]\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],k = 4) == [-1, -1, -1, -1, 99995, 99994, -1, -1, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 4) == [-1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 6) == [-1, -1, -1, -1, -1, -1, 7, 8, 9, 10, 11, 12, 13, 14, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == [-1, 8, 7, 6, 5, 4, 3, 2, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 8) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 8) == [-1, -1, -1, -1, -1, -1, -1, -1, 90, 100, 110, 120, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 0],k = 4) == [-1, -1, -1, -1, 55555, 44444, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 4) == [-1, -1, -1, -1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 0) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == [-1, -1, 3, 4, 5, 6, 7, 8, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 4) == [-1, -1, -1, -1, 60000, 50000, -1, -1, -1, -1]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 2) == [-1, -1, 15, 20, 25, 30, 35, 40, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 9) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 5, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0],k = 2) == [-1, -1, 60000, 40000, 60000, 40000, 60000, 40000, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5) == [-1, -1, -1, -1, -1, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 5) == [-1, -1, -1, -1, -1, 600, 700, 800, 900, 1000, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5) == [-1, -1, -1, -1, -1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 3) == [-1, -1, -1, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k = 0) == [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 4) == [-1, -1, -1, -1, 5, 6, 7, 8, 9, 10, 11, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == [-1, -1, -1, 40, 50, 60, 70, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == [-1, -1, -1, 0, 0, 0, 0, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [-1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1],k = 1) == [-1, 5, 5, 5, 5, 4, 6, 4, -1]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 5) == [-1, -1, -1, -1, -1, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 2) == [-1, -1, 3, 2, 1, 1, 1, 2, 3, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [-1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 2) == [-1, -1, 80000, 70000, 60000, 50000, 40000, 30000, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == [-1, -1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 2) == [-1, -1, 30, 40, 50, 60, 70, 80, -1, -1]\n assert candidate(nums = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],k = 4) == [-1, -1, -1, -1, 99999, 99999, -1, -1, -1, -1]\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k = 4) == [-1, -1, -1, -1, 100000, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == [-1, -1, -1, 40, 50, 60, 70, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 7) == [-1, -1, -1, -1, -1, -1, -1, 15, 17, 19, 21, 23, 25, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2) == [-1, -1, 300, 400, 500, 600, 700, 800, -1, -1]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == [-1, -1, -1, -1, -1, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 4) == [-1, -1, -1, -1, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == [-1, -1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 1) == [-1, 3, 5, 7, 9, 11, 13, 15, 17, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [6, 10, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 2) == [-1, -1, 5, 5, 4, 4, 5, 5, 4, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 2) == [-1, -1, 0, 0, 0, 0, 0, 0, -1, -1]\n", "comparison": "exact"}, "public_tests": ["[7,4,3,9,1,8,5,2,6]\n3", "[100000]\n0", "[8]\n100000"], "hints": ["To calculate the average of a subarray, you need the sum and the K. K is already given. How could you quickly calculate the sum of a subarray?", "Use the Prefix Sums method to calculate the subarray sums.", "It is possible that the sum of all the elements does not fit in a 32-bit integer type. Be sure to use a 64-bit integer type for the prefix sum array."], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().getAverages", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:42+00:00", "tests_total": 94, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["array", "sliding-window"]}, "language": "javascript", "interface": {"raw_signature": "var getAverages = function(nums, k) {", "container": null, "callable": "getAverages", "parameters": [{"name": "nums", "type": "number[]"}, {"name": "k", "type": "number"}], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2091, "task_id": "removing-minimum-and-maximum-from-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of distinct integers nums.\n\nThere is an element in nums that has the lowest value and an element that has the highest value. We call them the minimum and maximum respectively. Your goal is to remove both these elements from the array.\n\nA deletion is defined as either removing an element from the front of the array or removing an element from the back of the array.\n\nReturn the minimum number of deletions it would take to remove both the minimum and maximum element from the array.\n\nExample 1:\n\nInput: nums = [2,10,7,5,4,1,8,6]\nOutput: 5\nExplanation:\nThe minimum element in the array is nums[5], which is 1.\nThe maximum element in the array is nums[1], which is 10.\nWe can remove both the minimum and maximum by removing 2 elements from the front and 3 elements from the back.\nThis results in 2 + 3 = 5 deletions, which is the minimum number possible.\n\nExample 2:\n\nInput: nums = [0,-4,19,1,8,-2,-3,5]\nOutput: 3\nExplanation:\nThe minimum element in the array is nums[1], which is -4.\nThe maximum element in the array is nums[2], which is 19.\nWe can remove both the minimum and maximum by removing 3 elements from the front.\nThis results in only 3 deletions, which is the minimum number possible.\n\nExample 3:\n\nInput: nums = [101]\nOutput: 1\nExplanation:\nThere is only one element in the array, which makes it both the minimum and maximum element.\nWe can remove it with 1 deletion.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- -10^5 <= nums[i] <= 10^5\n- The integers in nums are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 10, 7, 5, 4, 1, 8, 6]) == 5\n assert candidate(nums = [100000, -100000, 50000, -50000]) == 2\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [101]) == 1\n assert candidate(nums = [3, 1, 2, 4, 5]) == 3\n assert candidate(nums = [100000, -100000, 50000, -50000, 0]) == 2\n assert candidate(nums = [0, -4, 19, 1, 8, -2, -3, 5]) == 3\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [1, 3, 2]) == 2\n assert candidate(nums = [3, 1]) == 2\n assert candidate(nums = [3, 2, 1]) == 2\n assert candidate(nums = [5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 2\n assert candidate(nums = [-1, 1]) == 2\n assert candidate(nums = [5, 3, 1, 2, 4]) == 3\n assert candidate(nums = [5, 3, 1, 4, 2]) == 3\n assert candidate(nums = [99, 97, 95, 93, 91, 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65, 63, 61, 59, 57, 55, 53, 51]) == 2\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991, -99990, -99989, -99988, -99987, -99986, -99985, -99984, -99983, -99982, -99981, -99980, -99979, -99978, -99977, -99976, -99975, -99974, -99973, -99972, -99971, -99970, 100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980, 99979, 99978, 99977, 99976, 99975, 99974, 99973, 99972, 99971, 99970]) == 32\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 2\n assert candidate(nums = [-50000, 49999, -49999, 49998, -49998, 49997, -49997, 49996, -49996, 49995]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 2\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [3, 1, 2, 5, 4, 6, 7, 8, 9, 10]) == 3\n assert candidate(nums = [-7, 10, 5, -3, 2, 8, 0, -1, 6, 4]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 2\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10\n assert candidate(nums = [3, 7, 1, 9, 5, 2, 8, 4, 6]) == 4\n assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500]) == 6\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 2\n assert candidate(nums = [30, 20, 10, 0, -10, -20, -30, 40, 50, 60, 70, 80, 90, 100]) == 8\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995]) == 2\n assert candidate(nums = [-1, -5, -3, -7, -2, -6, -4]) == 4\n assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500, 0]) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14]) == 13\n assert candidate(nums = [9, 3, 5, 2, 7, 6, 1, 8, 4]) == 4\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000, 75000, -75000, 12500, -12500]) == 2\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 2\n assert candidate(nums = [3, 1, 2, 5, 4]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1]) == 2\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9]) == 2\n assert candidate(nums = [5, 2, 8, 3, 7, 6, 4, 10, 1, 9]) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 2\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 2\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 2\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 100]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 2\n assert candidate(nums = [5, 1, 4, 2, 3, 6, 8, 7, 10, 9]) == 4\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [-5, -10, -3, -1, -8, -2, -7, -4, -6, -9]) == 4\n assert candidate(nums = [3, 1, 2]) == 2\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -1]) == 2\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7]) == 22\n assert candidate(nums = [40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21]) == 2\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, 0]) == 3\n assert candidate(nums = [1, 10, 3, 8, 5, 2, 7, 4, 6, 9]) == 2\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 6\n assert candidate(nums = [1000, 100, 10, 1, 0, -1, -10, -100, -1000, 500, 50, 5, 0.5, 0.05, 0.005, 0.0005, 5e-05]) == 9\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000, 12500, -12500, 6250, -6250]) == 2\n assert candidate(nums = [-10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 2\n assert candidate(nums = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(nums = [10, 2, 8, 6, 7, 3, 5, 1, 9, 4]) == 4\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 11\n assert candidate(nums = [-100000, 100000, 1, -1, 50000, -50000, 99999, -99999, 42, -42]) == 2\n assert candidate(nums = [7, 3, 5, 2, 8, 6, 4, 1]) == 4\n assert candidate(nums = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 2\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [20, 18, 19, 16, 17, 14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 1]) == 2\n assert candidate(nums = [9, 3, 15, 1, 12, 7, 8, 6, 10, 2]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 2\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6]) == 3\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 8, 18, 28, 38, 48, 58, 68, 78, 88, 98, 7, 17, 27, 37, 47, 57, 67, 77, 87, 97, 6, 16, 26, 36, 46, 56, 66, 76, 86, 96, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 4, 14, 24, 34, 44, 54, 64, 74, 84, 94, 3, 13, 23, 33, 43, 53, 63, 73, 83, 93, 2, 12, 22, 32, 42, 52, 62, 72, 82, 92, 1, 11, 21, 31, 41, 51, 61, 71, 81, 91]) == 20\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 2\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993, 9, 99992, 10, 99991, 11, 99990, 12, 99989, 13, 99988, 14, 99987, 15, 99986, 16, 99985, 17, 99984, 18, 99983, 19, 99982, 20, 99981, 21, 99980, 22, 99979, 23, 99978, 24, 99977, 25, 99976, 26, 99975, 27, 99974, 28, 99973, 29, 99972, 30, 99971]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7]) == 2\n", "comparison": "exact"}, "public_tests": ["[2,10,7,5,4,1,8,6]", "[0,-4,19,1,8,-2,-3,5]", "[101]"], "hints": ["There can only be three scenarios for deletions such that both minimum and maximum elements are removed:", "Scenario 1: Both elements are removed by only deleting from the front.", "Scenario 2: Both elements are removed by only deleting from the back.", "Scenario 3: Delete from the front to remove one of the elements, and delete from the back to remove the other element.", "Compare which of the three scenarios results in the minimum number of moves."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumDeletions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:45+00:00", "tests_total": 102, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "greedy"]}, "language": "javascript", "interface": {"raw_signature": "var minimumDeletions = function(nums) {", "container": null, "callable": "minimumDeletions", "parameters": [{"name": "nums", "type": "number[]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2091, "task_id": "removing-minimum-and-maximum-from-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of distinct integers nums.\n\nThere is an element in nums that has the lowest value and an element that has the highest value. We call them the minimum and maximum respectively. Your goal is to remove both these elements from the array.\n\nA deletion is defined as either removing an element from the front of the array or removing an element from the back of the array.\n\nReturn the minimum number of deletions it would take to remove both the minimum and maximum element from the array.\n\nExample 1:\n\nInput: nums = [2,10,7,5,4,1,8,6]\nOutput: 5\nExplanation:\nThe minimum element in the array is nums[5], which is 1.\nThe maximum element in the array is nums[1], which is 10.\nWe can remove both the minimum and maximum by removing 2 elements from the front and 3 elements from the back.\nThis results in 2 + 3 = 5 deletions, which is the minimum number possible.\n\nExample 2:\n\nInput: nums = [0,-4,19,1,8,-2,-3,5]\nOutput: 3\nExplanation:\nThe minimum element in the array is nums[1], which is -4.\nThe maximum element in the array is nums[2], which is 19.\nWe can remove both the minimum and maximum by removing 3 elements from the front.\nThis results in only 3 deletions, which is the minimum number possible.\n\nExample 3:\n\nInput: nums = [101]\nOutput: 1\nExplanation:\nThere is only one element in the array, which makes it both the minimum and maximum element.\nWe can remove it with 1 deletion.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- -10^5 <= nums[i] <= 10^5\n- The integers in nums are distinct.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 10, 7, 5, 4, 1, 8, 6]) == 5\n assert candidate(nums = [100000, -100000, 50000, -50000]) == 2\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [101]) == 1\n assert candidate(nums = [3, 1, 2, 4, 5]) == 3\n assert candidate(nums = [100000, -100000, 50000, -50000, 0]) == 2\n assert candidate(nums = [0, -4, 19, 1, 8, -2, -3, 5]) == 3\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [1, 3, 2]) == 2\n assert candidate(nums = [3, 1]) == 2\n assert candidate(nums = [3, 2, 1]) == 2\n assert candidate(nums = [5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 2\n assert candidate(nums = [-1, 1]) == 2\n assert candidate(nums = [5, 3, 1, 2, 4]) == 3\n assert candidate(nums = [5, 3, 1, 4, 2]) == 3\n assert candidate(nums = [99, 97, 95, 93, 91, 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65, 63, 61, 59, 57, 55, 53, 51]) == 2\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991, -99990, -99989, -99988, -99987, -99986, -99985, -99984, -99983, -99982, -99981, -99980, -99979, -99978, -99977, -99976, -99975, -99974, -99973, -99972, -99971, -99970, 100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980, 99979, 99978, 99977, 99976, 99975, 99974, 99973, 99972, 99971, 99970]) == 32\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 2\n assert candidate(nums = [-50000, 49999, -49999, 49998, -49998, 49997, -49997, 49996, -49996, 49995]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 2\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [3, 1, 2, 5, 4, 6, 7, 8, 9, 10]) == 3\n assert candidate(nums = [-7, 10, 5, -3, 2, 8, 0, -1, 6, 4]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 2\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10\n assert candidate(nums = [3, 7, 1, 9, 5, 2, 8, 4, 6]) == 4\n assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500]) == 6\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 2\n assert candidate(nums = [30, 20, 10, 0, -10, -20, -30, 40, 50, 60, 70, 80, 90, 100]) == 8\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995]) == 2\n assert candidate(nums = [-1, -5, -3, -7, -2, -6, -4]) == 4\n assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500, 0]) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14]) == 13\n assert candidate(nums = [9, 3, 5, 2, 7, 6, 1, 8, 4]) == 4\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000, 75000, -75000, 12500, -12500]) == 2\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 2\n assert candidate(nums = [3, 1, 2, 5, 4]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1]) == 2\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9]) == 2\n assert candidate(nums = [5, 2, 8, 3, 7, 6, 4, 10, 1, 9]) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 2\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 2\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 2\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 100]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 2\n assert candidate(nums = [5, 1, 4, 2, 3, 6, 8, 7, 10, 9]) == 4\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [-5, -10, -3, -1, -8, -2, -7, -4, -6, -9]) == 4\n assert candidate(nums = [3, 1, 2]) == 2\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -1]) == 2\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7]) == 22\n assert candidate(nums = [40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21]) == 2\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, 0]) == 3\n assert candidate(nums = [1, 10, 3, 8, 5, 2, 7, 4, 6, 9]) == 2\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 6\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000, 12500, -12500, 6250, -6250]) == 2\n assert candidate(nums = [-10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 2\n assert candidate(nums = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(nums = [10, 2, 8, 6, 7, 3, 5, 1, 9, 4]) == 4\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 11\n assert candidate(nums = [-100000, 100000, 1, -1, 50000, -50000, 99999, -99999, 42, -42]) == 2\n assert candidate(nums = [7, 3, 5, 2, 8, 6, 4, 1]) == 4\n assert candidate(nums = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 2\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [20, 18, 19, 16, 17, 14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 1]) == 2\n assert candidate(nums = [9, 3, 15, 1, 12, 7, 8, 6, 10, 2]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 2\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6]) == 3\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 8, 18, 28, 38, 48, 58, 68, 78, 88, 98, 7, 17, 27, 37, 47, 57, 67, 77, 87, 97, 6, 16, 26, 36, 46, 56, 66, 76, 86, 96, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 4, 14, 24, 34, 44, 54, 64, 74, 84, 94, 3, 13, 23, 33, 43, 53, 63, 73, 83, 93, 2, 12, 22, 32, 42, 52, 62, 72, 82, 92, 1, 11, 21, 31, 41, 51, 61, 71, 81, 91]) == 20\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 2\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993, 9, 99992, 10, 99991, 11, 99990, 12, 99989, 13, 99988, 14, 99987, 15, 99986, 16, 99985, 17, 99984, 18, 99983, 19, 99982, 20, 99981, 21, 99980, 22, 99979, 23, 99978, 24, 99977, 25, 99976, 26, 99975, 27, 99974, 28, 99973, 29, 99972, 30, 99971]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7]) == 2\n", "comparison": "exact"}, "public_tests": ["[2,10,7,5,4,1,8,6]", "[0,-4,19,1,8,-2,-3,5]", "[101]"], "hints": ["There can only be three scenarios for deletions such that both minimum and maximum elements are removed:", "Scenario 1: Both elements are removed by only deleting from the front.", "Scenario 2: Both elements are removed by only deleting from the back.", "Scenario 3: Delete from the front to remove one of the elements, and delete from the back to remove the other element.", "Compare which of the three scenarios results in the minimum number of moves."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumDeletions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:45+00:00", "tests_total": 102, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "greedy"]}, "language": "javascript", "interface": {"raw_signature": "var minimumDeletions = function(nums) {", "container": null, "callable": "minimumDeletions", "parameters": [{"name": "nums", "type": "number[]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2092, "task_id": "find-all-people-with-secret", "difficulty": "Hard", "problem_description": "You are given an integer n indicating there are n people numbered from 0 to n - 1. You are also given a 0-indexed 2D integer array meetings where meetings[i] = [x_i, y_i, time_i] indicates that person x_i and person y_i have a meeting at time_i. A person may attend multiple meetings at the same time. Finally, you are given an integer firstPerson.\n\nPerson 0 has a secret and initially shares the secret with a person firstPerson at time 0. This secret is then shared every time a meeting takes place with a person that has the secret. More formally, for every meeting, if a person x_i has the secret at time_i, then they will share the secret with person y_i, and vice versa.\n\nThe secrets are shared instantaneously. That is, a person may receive the secret and share it with people in other meetings within the same time frame.\n\nReturn a list of all the people that have the secret after all the meetings have taken place. You may return the answer in any order.\n\nExample 1:\n\nInput: n = 6, meetings = [[1,2,5],[2,3,8],[1,5,10]], firstPerson = 1\nOutput: [0,1,2,3,5]\nExplanation:\nAt time 0, person 0 shares the secret with person 1.\nAt time 5, person 1 shares the secret with person 2.\nAt time 8, person 2 shares the secret with person 3.\nAt time 10, person 1 shares the secret with person 5.\nThus, people 0, 1, 2, 3, and 5 know the secret after all the meetings.\n\nExample 2:\n\nInput: n = 4, meetings = [[3,1,3],[1,2,2],[0,3,3]], firstPerson = 3\nOutput: [0,1,3]\nExplanation:\nAt time 0, person 0 shares the secret with person 3.\nAt time 2, neither person 1 nor person 2 know the secret.\nAt time 3, person 3 shares the secret with person 0 and person 1.\nThus, people 0, 1, and 3 know the secret after all the meetings.\n\nExample 3:\n\nInput: n = 5, meetings = [[3,4,2],[1,2,1],[2,3,1]], firstPerson = 1\nOutput: [0,1,2,3,4]\nExplanation:\nAt time 0, person 0 shares the secret with person 1.\nAt time 1, person 1 shares the secret with person 2, and person 2 shares the secret with person 3.\nNote that person 2 can share the secret at the same time as receiving it.\nAt time 2, person 3 shares the secret with person 4.\nThus, people 0, 1, 2, 3, and 4 know the secret after all the meetings.\n\nConstraints:\n\n- 2 <= n <= 10^5\n- 1 <= meetings.length <= 10^5\n- meetings[i].length == 3\n- 0 <= x_i, y_i<= n - 1\n- x_i != y_i\n- 1 <= time_i <= 10^5\n- 1 <= firstPerson <= n - 1\n", "canonical_tests": {"language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return result == expected\n\n\ndef check(candidate):\n assert answers_match(candidate(n=3, meetings=[[0, 1, 10], [1, 2, 20]], firstPerson=1), [0, 1, 2])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]], firstPerson=5), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=3, meetings=[[0, 1, 1], [1, 2, 2], [0, 2, 3]], firstPerson=2), [0, 1, 2])\n assert answers_match(candidate(n=5, meetings=[[3, 4, 2], [1, 2, 1], [2, 3, 1]], firstPerson=1), [0, 1, 2, 3, 4])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 10], [1, 2, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=4, meetings=[[3, 1, 3], [1, 2, 2], [0, 3, 3]], firstPerson=3), [0, 1, 3])\n assert answers_match(candidate(n=7, meetings=[[0, 2, 1], [1, 3, 2], [2, 4, 3], [3, 5, 4], [4, 6, 5]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=3, meetings=[[0, 1, 10], [1, 2, 20], [2, 0, 30]], firstPerson=2), [0, 1, 2])\n assert answers_match(candidate(n=3, meetings=[[0, 1, 1], [1, 2, 2], [0, 2, 3]], firstPerson=1), [0, 1, 2])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=6, meetings=[[1, 2, 5], [2, 3, 8], [1, 5, 10]], firstPerson=1), [0, 1, 2, 3, 5])\n assert answers_match(candidate(n=7, meetings=[[0, 2, 1], [1, 3, 1], [4, 5, 1], [5, 6, 1]], firstPerson=2), [0, 2])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55], [11, 12, 60], [12, 13, 65], [13, 14, 70], [14, 0, 75]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [0, 2, 1], [0, 3, 1], [0, 4, 1], [1, 5, 2], [2, 6, 2], [3, 7, 2], [4, 8, 2], [5, 9, 3], [6, 9, 3], [7, 9, 3], [8, 9, 3]], firstPerson=9), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=12, meetings=[[0, 1, 1], [1, 2, 2], [2, 0, 3], [3, 4, 4], [4, 5, 5], [5, 3, 6], [6, 7, 7], [7, 8, 8], [8, 6, 9], [9, 10, 10], [10, 11, 11], [11, 9, 12]], firstPerson=1), [0, 1, 2])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3]], firstPerson=2), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=11, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 0, 11]], firstPerson=10), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])\n assert answers_match(candidate(n=12, meetings=[[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 0, 1], [0, 5, 2], [1, 6, 2], [2, 7, 2], [3, 8, 2], [4, 9, 2], [5, 10, 2], [6, 11, 2], [7, 0, 2], [8, 1, 2], [9, 2, 2], [10, 3, 2], [11, 4, 2]], firstPerson=5), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])\n assert answers_match(candidate(n=20, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19]], firstPerson=10), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])\n assert answers_match(candidate(n=12, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12]], firstPerson=6), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])\n assert answers_match(candidate(n=20, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 0, 20]], firstPerson=10), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [0, 7, 9], [1, 6, 10], [2, 5, 11], [3, 4, 12]], firstPerson=4), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 2, 11], [1, 3, 12], [2, 4, 13], [3, 5, 14], [4, 6, 15], [5, 7, 16], [6, 8, 17], [7, 9, 18], [8, 0, 19], [9, 1, 20]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=12, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11]], firstPerson=5), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])\n assert answers_match(candidate(n=6, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 0, 6]], firstPerson=1), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 0, 1]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=12, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12]], firstPerson=5), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])\n assert answers_match(candidate(n=9, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 0, 9], [0, 5, 10]], firstPerson=5), [0, 1, 2, 3, 4, 5, 6, 7, 8])\n assert answers_match(candidate(n=20, meetings=[[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 0, 1]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 10], [0, 2, 10], [1, 3, 20], [1, 4, 20], [2, 5, 30], [2, 6, 30], [3, 7, 40], [3, 8, 40], [4, 9, 50], [4, 10, 50], [5, 11, 60], [5, 12, 60], [6, 13, 70], [6, 14, 70]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1]], firstPerson=5), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=10, meetings=[[0, 9, 1], [1, 8, 2], [2, 7, 3], [3, 6, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]], firstPerson=5), [0, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=6, meetings=[[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50]], firstPerson=1), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 0, 2], [1, 3, 3], [2, 4, 3], [3, 5, 3], [4, 6, 3], [5, 7, 3], [6, 8, 3], [7, 9, 3], [8, 0, 3], [9, 1, 3]], firstPerson=4), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=10, meetings=[[0, 9, 1], [1, 8, 2], [2, 7, 3], [3, 6, 4], [4, 5, 5], [5, 4, 5], [6, 3, 4], [7, 2, 3], [8, 1, 2], [9, 0, 1]], firstPerson=5), [0, 4, 5, 9])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3], [3, 7, 4], [3, 8, 4], [4, 9, 5], [4, 10, 5], [5, 11, 6], [5, 12, 6], [6, 13, 7], [6, 14, 7]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [0, 2, 1], [0, 3, 1], [0, 4, 1], [0, 5, 1], [0, 6, 1], [0, 7, 1], [0, 8, 1], [0, 9, 1]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=9, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 0, 9], [0, 2, 10], [1, 3, 11], [2, 4, 12], [3, 5, 13], [4, 6, 14], [5, 7, 15], [6, 8, 16], [7, 0, 17], [8, 1, 18]], firstPerson=4), [0, 1, 2, 3, 4, 5, 6, 7, 8])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [1, 3, 9], [3, 5, 10], [5, 7, 11], [7, 1, 12]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5]], firstPerson=4), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=12, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12], [0, 11, 13]], firstPerson=5), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3], [3, 4, 4], [3, 5, 5], [4, 6, 6], [5, 6, 7]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [0, 6, 70]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 9, 11], [1, 8, 12], [2, 7, 13], [3, 6, 14], [4, 5, 15]], firstPerson=5), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 1], [0, 2, 2], [1, 3, 3], [2, 4, 4], [3, 5, 5], [4, 6, 6], [5, 6, 7]], firstPerson=2), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=6, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5]], firstPerson=1), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(n=10, meetings=[[0, 9, 10], [1, 2, 10], [3, 4, 10], [5, 6, 10], [7, 8, 10], [1, 3, 10], [2, 4, 10], [5, 7, 10], [6, 8, 10]], firstPerson=1), [0, 1, 2, 3, 4, 9])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 2], [2, 0, 3], [0, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 0, 11]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 2], [4, 5, 3], [5, 6, 3], [6, 7, 4], [7, 8, 4], [8, 9, 5]], firstPerson=4), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 1], [2, 3, 2], [4, 5, 3], [6, 7, 4], [0, 2, 5], [1, 3, 6], [2, 4, 7], [3, 5, 8], [4, 6, 9], [5, 7, 10]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 0, 5]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=6, meetings=[[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 2], [4, 5, 3], [5, 0, 3], [1, 4, 4], [2, 5, 5]], firstPerson=2), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 30], [5, 6, 35], [6, 0, 40]], firstPerson=6), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=8, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [0, 3, 9], [1, 5, 10]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6, 7])\n assert answers_match(candidate(n=10, meetings=[[0, 4, 5], [4, 5, 5], [0, 1, 6], [1, 2, 6], [2, 3, 7], [3, 4, 7], [4, 6, 8], [5, 7, 9], [6, 8, 10], [7, 9, 11]], firstPerson=4), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=20, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 0, 20]], firstPerson=19), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15], [0, 7, 16], [7, 11, 17], [11, 14, 18]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 0, 7], [0, 6, 8]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 1], [2, 3, 1], [4, 5, 1], [6, 7, 1], [8, 9, 1], [10, 11, 1], [12, 13, 1], [13, 14, 1], [0, 2, 2], [1, 3, 2], [4, 6, 2], [5, 7, 2], [8, 10, 2], [9, 11, 2], [12, 14, 2], [13, 0, 3], [14, 1, 3], [0, 4, 3], [1, 5, 3], [2, 6, 3], [3, 7, 3], [4, 8, 3], [5, 9, 3], [6, 10, 3], [7, 11, 3], [8, 12, 3], [9, 13, 3], [10, 14, 3]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3], [3, 4, 4], [3, 5, 5], [4, 6, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 0, 11], [0, 3, 12], [1, 5, 13], [2, 4, 14]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=10, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10]], firstPerson=9), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 1], [1, 2, 2], [0, 3, 3], [3, 4, 4], [0, 5, 5], [5, 6, 6], [2, 4, 7], [1, 6, 8]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6])\n assert answers_match(candidate(n=6, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [0, 5, 6]], firstPerson=1), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=10, meetings=[[0, 9, 10], [1, 8, 10], [2, 7, 10], [3, 6, 10], [4, 5, 10], [0, 1, 20], [1, 2, 20], [2, 3, 20], [3, 4, 20], [4, 5, 20]], firstPerson=9), [0, 1, 2, 3, 4, 5, 9])\n assert answers_match(candidate(n=12, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12], [0, 6, 13], [1, 7, 14], [2, 8, 15], [3, 9, 16], [4, 10, 17], [5, 11, 18]], firstPerson=6), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])\n assert answers_match(candidate(n=6, meetings=[[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5]], firstPerson=1), [0, 1, 2, 3, 4, 5])\n assert answers_match(candidate(n=9, meetings=[[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 0, 9], [0, 2, 10], [1, 3, 11], [2, 4, 12], [3, 5, 13], [4, 6, 14], [5, 7, 15], [6, 8, 16], [7, 0, 17], [8, 1, 18]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8])\n assert answers_match(candidate(n=15, meetings=[[0, 1, 10], [1, 2, 11], [2, 3, 12], [3, 4, 13], [4, 5, 14], [5, 6, 15], [6, 7, 16], [7, 8, 17], [8, 9, 18], [9, 10, 19], [10, 11, 20], [11, 12, 21], [12, 13, 22], [13, 14, 23]], firstPerson=7), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])\n assert answers_match(candidate(n=12, meetings=[[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 0, 1]], firstPerson=1), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])\n assert answers_match(candidate(n=7, meetings=[[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 4], [1, 5, 5], [2, 6, 6], [3, 6, 6], [4, 5, 5], [4, 6, 6], [5, 6, 6]], firstPerson=3), [0, 1, 2, 3, 4, 5, 6])\n", "comparison": "unordered"}, "public_tests": ["6\n[[1,2,5],[2,3,8],[1,5,10]]\n1", "4\n[[3,1,3],[1,2,2],[0,3,3]]\n3", "5\n[[3,4,2],[1,2,1],[2,3,1]]\n1"], "hints": ["Could you model all the meetings happening at the same time as a graph?", "What data structure can you use to efficiently share the secret?", "You can use the union-find data structure to quickly determine who knows the secret and share the secret."], "metadata": {"canonical_parameter_names": ["n", "meetings", "firstPerson"], "leetcode_dataset_entry_point": "Solution().findAllPeople", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:48+00:00", "tests_total": 84, "tests_dropped": 4, "flags": ["any_order"], "topic_tags": ["depth-first-search", "breadth-first-search", "union-find", "graph", "sorting"]}, "language": "javascript", "interface": {"raw_signature": "var findAllPeople = function(n, meetings, firstPerson) {", "container": null, "callable": "findAllPeople", "parameters": [{"name": "n", "type": "number"}, {"name": "meetings", "type": "number[][]"}, {"name": "firstPerson", "type": "number"}], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2094, "task_id": "finding-3-digit-even-numbers", "difficulty": "Easy", "problem_description": "You are given an integer array digits, where each element is a digit. The array may contain duplicates.\n\nYou need to find all the unique integers that follow the given requirements:\n\n- The integer consists of the concatenation of three elements from digits in any arbitrary order.\n- The integer does not have leading zeros.\n- The integer is even.\n\nFor example, if the given digits were [1, 2, 3], integers 132 and 312 follow the requirements.\n\nReturn a sorted array of the unique integers.\n\nExample 1:\n\nInput: digits = [2,1,3,0]\nOutput: [102,120,130,132,210,230,302,310,312,320]\nExplanation: All the possible integers that follow the requirements are in the output array.\nNotice that there are no odd integers or integers with leading zeros.\n\nExample 2:\n\nInput: digits = [2,2,8,8,2]\nOutput: [222,228,282,288,822,828,882]\nExplanation: The same digit can be used as many times as it appears in digits.\nIn this example, the digit 8 is used twice each time in 288, 828, and 882.\n\nExample 3:\n\nInput: digits = [3,7,5]\nOutput: []\nExplanation: No even integers can be formed using the given digits.\n\nConstraints:\n\n- 3 <= digits.length <= 100\n- 0 <= digits[i] <= 9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(digits = [1, 1, 1, 1, 1, 1]) == []\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == []\n assert candidate(digits = [2, 4, 6, 8, 0]) == [204, 206, 208, 240, 246, 248, 260, 264, 268, 280, 284, 286, 402, 406, 408, 420, 426, 428, 460, 462, 468, 480, 482, 486, 602, 604, 608, 620, 624, 628, 640, 642, 648, 680, 682, 684, 802, 804, 806, 820, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [1, 0, 2, 4, 3, 5, 7, 9]) == [102, 104, 120, 124, 130, 132, 134, 140, 142, 150, 152, 154, 170, 172, 174, 190, 192, 194, 204, 210, 214, 230, 234, 240, 250, 254, 270, 274, 290, 294, 302, 304, 310, 312, 314, 320, 324, 340, 342, 350, 352, 354, 370, 372, 374, 390, 392, 394, 402, 410, 412, 420, 430, 432, 450, 452, 470, 472, 490, 492, 502, 504, 510, 512, 514, 520, 524, 530, 532, 534, 540, 542, 570, 572, 574, 590, 592, 594, 702, 704, 710, 712, 714, 720, 724, 730, 732, 734, 740, 742, 750, 752, 754, 790, 792, 794, 902, 904, 910, 912, 914, 920, 924, 930, 932, 934, 940, 942, 950, 952, 954, 970, 972, 974]\n assert candidate(digits = [2, 1, 3, 0]) == [102, 120, 130, 132, 210, 230, 302, 310, 312, 320]\n assert candidate(digits = [0, 2, 4, 6, 8]) == [204, 206, 208, 240, 246, 248, 260, 264, 268, 280, 284, 286, 402, 406, 408, 420, 426, 428, 460, 462, 468, 480, 482, 486, 602, 604, 608, 620, 624, 628, 640, 642, 648, 680, 682, 684, 802, 804, 806, 820, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [1, 0, 0, 0]) == [100]\n assert candidate(digits = [2, 4, 6, 8]) == [246, 248, 264, 268, 284, 286, 426, 428, 462, 468, 482, 486, 624, 628, 642, 648, 682, 684, 824, 826, 842, 846, 862, 864]\n assert candidate(digits = [1, 3, 5, 7, 9]) == []\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == []\n assert candidate(digits = [2, 2, 8, 8, 2]) == [222, 228, 282, 288, 822, 828, 882]\n assert candidate(digits = [3, 7, 5]) == []\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [0, 0, 0]) == []\n assert candidate(digits = [0, 2, 2, 2, 4, 4, 4, 6, 6, 6, 8, 8, 8]) == [202, 204, 206, 208, 220, 222, 224, 226, 228, 240, 242, 244, 246, 248, 260, 262, 264, 266, 268, 280, 282, 284, 286, 288, 402, 404, 406, 408, 420, 422, 424, 426, 428, 440, 442, 444, 446, 448, 460, 462, 464, 466, 468, 480, 482, 484, 486, 488, 602, 604, 606, 608, 620, 622, 624, 626, 628, 640, 642, 644, 646, 648, 660, 662, 664, 666, 668, 680, 682, 684, 686, 688, 802, 804, 806, 808, 820, 822, 824, 826, 828, 840, 842, 844, 846, 848, 860, 862, 864, 866, 868, 880, 882, 884, 886, 888]\n assert candidate(digits = [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0]) == [100, 102, 110, 112, 120, 122, 130, 132, 200, 202, 210, 212, 220, 222, 230, 232, 300, 302, 310, 312, 320, 322, 330, 332]\n assert candidate(digits = [9, 9, 9, 0, 0, 0, 1, 1, 1, 2]) == [100, 102, 110, 112, 120, 190, 192, 200, 210, 290, 900, 902, 910, 912, 920, 990, 992]\n assert candidate(digits = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [0, 0, 0, 1, 1, 1, 2, 2, 2]) == [100, 102, 110, 112, 120, 122, 200, 202, 210, 212, 220, 222]\n assert candidate(digits = [0, 0, 2, 4, 6, 8]) == [200, 204, 206, 208, 240, 246, 248, 260, 264, 268, 280, 284, 286, 400, 402, 406, 408, 420, 426, 428, 460, 462, 468, 480, 482, 486, 600, 602, 604, 608, 620, 624, 628, 640, 642, 648, 680, 682, 684, 800, 802, 804, 806, 820, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 0]) == [990]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0]) == [200, 202, 220, 222]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 0, 0, 0, 1, 1, 1]) == [100, 110, 190, 900, 910, 990]\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]) == [100, 110]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == []\n assert candidate(digits = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == [888]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 0]) == [550]\n assert candidate(digits = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == []\n assert candidate(digits = [2, 2, 0, 0, 8, 8]) == [200, 202, 208, 220, 228, 280, 282, 288, 800, 802, 808, 820, 822, 828, 880, 882]\n assert candidate(digits = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [800, 808, 880, 888]\n assert candidate(digits = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == [112, 114, 122, 124, 132, 134, 142, 144, 212, 214, 222, 224, 232, 234, 242, 244, 312, 314, 322, 324, 332, 334, 342, 344, 412, 414, 422, 424, 432, 434, 442, 444]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0]) == [550]\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == [200, 202, 204, 206, 208, 220, 224, 226, 228, 240, 242, 244, 246, 248, 260, 262, 264, 266, 268, 280, 282, 284, 286, 288, 400, 402, 404, 406, 408, 420, 422, 424, 426, 428, 440, 442, 446, 448, 460, 462, 464, 466, 468, 480, 482, 484, 486, 488, 600, 602, 604, 606, 608, 620, 622, 624, 626, 628, 640, 642, 644, 646, 648, 660, 662, 664, 668, 680, 682, 684, 686, 688, 800, 802, 804, 806, 808, 820, 822, 824, 826, 828, 840, 842, 844, 846, 848, 860, 862, 864, 866, 868, 880, 882, 884, 886]\n assert candidate(digits = [0, 0, 1, 2, 4, 6]) == [100, 102, 104, 106, 120, 124, 126, 140, 142, 146, 160, 162, 164, 200, 204, 206, 210, 214, 216, 240, 246, 260, 264, 400, 402, 406, 410, 412, 416, 420, 426, 460, 462, 600, 602, 604, 610, 612, 614, 620, 624, 640, 642]\n assert candidate(digits = [4, 4, 4, 4, 4, 4, 4]) == [444]\n assert candidate(digits = [4, 4, 4, 4, 1, 1, 1, 1, 0, 0, 0, 0]) == [100, 104, 110, 114, 140, 144, 400, 404, 410, 414, 440, 444]\n assert candidate(digits = [0, 2, 2, 0, 4, 6, 8]) == [200, 202, 204, 206, 208, 220, 224, 226, 228, 240, 242, 246, 248, 260, 262, 264, 268, 280, 282, 284, 286, 400, 402, 406, 408, 420, 422, 426, 428, 460, 462, 468, 480, 482, 486, 600, 602, 604, 608, 620, 622, 624, 628, 640, 642, 648, 680, 682, 684, 800, 802, 804, 806, 820, 822, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [112, 122, 212, 222]\n assert candidate(digits = [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [124, 126, 128, 132, 134, 136, 138, 142, 146, 148, 152, 154, 156, 158, 162, 164, 168, 172, 174, 176, 178, 182, 184, 186, 192, 194, 196, 198, 214, 216, 218, 234, 236, 238, 246, 248, 254, 256, 258, 264, 268, 274, 276, 278, 284, 286, 294, 296, 298, 312, 314, 316, 318, 324, 326, 328, 342, 346, 348, 352, 354, 356, 358, 362, 364, 368, 372, 374, 376, 378, 382, 384, 386, 392, 394, 396, 398, 412, 416, 418, 426, 428, 432, 436, 438, 452, 456, 458, 462, 468, 472, 476, 478, 482, 486, 492, 496, 498, 512, 514, 516, 518, 524, 526, 528, 532, 534, 536, 538, 542, 546, 548, 562, 564, 568, 572, 574, 576, 578, 582, 584, 586, 592, 594, 596, 598, 612, 614, 618, 624, 628, 632, 634, 638, 642, 648, 652, 654, 658, 672, 674, 678, 682, 684, 692, 694, 698, 712, 714, 716, 718, 724, 726, 728, 732, 734, 736, 738, 742, 746, 748, 752, 754, 756, 758, 762, 764, 768, 782, 784, 786, 792, 794, 796, 798, 812, 814, 816, 824, 826, 832, 834, 836, 842, 846, 852, 854, 856, 862, 864, 872, 874, 876, 892, 894, 896, 912, 914, 916, 918, 924, 926, 928, 932, 934, 936, 938, 942, 946, 948, 952, 954, 956, 958, 962, 964, 968, 972, 974, 976, 978, 982, 984, 986]\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [100, 102, 110, 112, 120, 122, 200, 202, 210, 212, 220, 222]\n assert candidate(digits = [2, 4, 6, 8, 0, 0, 0, 0, 0, 0]) == [200, 204, 206, 208, 240, 246, 248, 260, 264, 268, 280, 284, 286, 400, 402, 406, 408, 420, 426, 428, 460, 462, 468, 480, 482, 486, 600, 602, 604, 608, 620, 624, 628, 640, 642, 648, 680, 682, 684, 800, 802, 804, 806, 820, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == [112, 114, 116, 118, 122, 124, 126, 128, 132, 134, 136, 138, 142, 144, 146, 148, 152, 154, 156, 158, 162, 164, 166, 168, 172, 174, 176, 178, 182, 184, 186, 188, 192, 194, 196, 198, 212, 214, 216, 218, 222, 224, 226, 228, 232, 234, 236, 238, 242, 244, 246, 248, 252, 254, 256, 258, 262, 264, 266, 268, 272, 274, 276, 278, 282, 284, 286, 288, 292, 294, 296, 298, 312, 314, 316, 318, 322, 324, 326, 328, 332, 334, 336, 338, 342, 344, 346, 348, 352, 354, 356, 358, 362, 364, 366, 368, 372, 374, 376, 378, 382, 384, 386, 388, 392, 394, 396, 398, 412, 414, 416, 418, 422, 424, 426, 428, 432, 434, 436, 438, 442, 444, 446, 448, 452, 454, 456, 458, 462, 464, 466, 468, 472, 474, 476, 478, 482, 484, 486, 488, 492, 494, 496, 498, 512, 514, 516, 518, 522, 524, 526, 528, 532, 534, 536, 538, 542, 544, 546, 548, 552, 554, 556, 558, 562, 564, 566, 568, 572, 574, 576, 578, 582, 584, 586, 588, 592, 594, 596, 598, 612, 614, 616, 618, 622, 624, 626, 628, 632, 634, 636, 638, 642, 644, 646, 648, 652, 654, 656, 658, 662, 664, 666, 668, 672, 674, 676, 678, 682, 684, 686, 688, 692, 694, 696, 698, 712, 714, 716, 718, 722, 724, 726, 728, 732, 734, 736, 738, 742, 744, 746, 748, 752, 754, 756, 758, 762, 764, 766, 768, 772, 774, 776, 778, 782, 784, 786, 788, 792, 794, 796, 798, 812, 814, 816, 818, 822, 824, 826, 828, 832, 834, 836, 838, 842, 844, 846, 848, 852, 854, 856, 858, 862, 864, 866, 868, 872, 874, 876, 878, 882, 884, 886, 888, 892, 894, 896, 898, 912, 914, 916, 918, 922, 924, 926, 928, 932, 934, 936, 938, 942, 944, 946, 948, 952, 954, 956, 958, 962, 964, 966, 968, 972, 974, 976, 978, 982, 984, 986, 988, 992, 994, 996, 998]\n assert candidate(digits = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 666, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 888, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [222]\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == []\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [222]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == [112]\n assert candidate(digits = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == [112, 122, 132, 212, 222, 232, 312, 322, 332]\n assert candidate(digits = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == []\n assert candidate(digits = [1, 0, 2, 3, 4, 5, 6, 7, 8, 9]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == []\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == []\n assert candidate(digits = [5, 5, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [222, 252, 522, 552]\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == [112, 122, 212, 222]\n assert candidate(digits = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [100, 110]\n assert candidate(digits = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [118, 188, 818, 888]\n assert candidate(digits = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == [500, 550]\n assert candidate(digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0]) == [100, 102, 104, 106, 108, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2]) == [200, 202, 220, 222]\n assert candidate(digits = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == [100, 102, 104, 120, 124, 130, 132, 134, 140, 142, 150, 152, 154, 200, 204, 210, 214, 230, 234, 240, 250, 254, 300, 302, 304, 310, 312, 314, 320, 324, 340, 342, 350, 352, 354, 400, 402, 410, 412, 420, 430, 432, 450, 452, 500, 502, 504, 510, 512, 514, 520, 524, 530, 532, 534, 540, 542]\n assert candidate(digits = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == [444]\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [222]\n assert candidate(digits = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == []\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == []\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == []\n assert candidate(digits = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == [112, 122, 212, 222]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == [122, 124, 126, 132, 134, 136, 142, 144, 146, 152, 154, 156, 162, 164, 166, 212, 214, 216, 224, 226, 232, 234, 236, 242, 244, 246, 252, 254, 256, 262, 264, 266, 312, 314, 316, 322, 324, 326, 332, 334, 336, 342, 344, 346, 352, 354, 356, 362, 364, 366, 412, 414, 416, 422, 424, 426, 432, 434, 436, 442, 446, 452, 454, 456, 462, 464, 466, 512, 514, 516, 522, 524, 526, 532, 534, 536, 542, 544, 546, 552, 554, 556, 562, 564, 566, 612, 614, 616, 622, 624, 626, 632, 634, 636, 642, 644, 646, 652, 654, 656, 662, 664]\n assert candidate(digits = [0, 1, 2, 2, 4, 6, 8, 8, 8, 9]) == [102, 104, 106, 108, 120, 122, 124, 126, 128, 140, 142, 146, 148, 160, 162, 164, 168, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 240, 242, 246, 248, 260, 262, 264, 268, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 402, 406, 408, 410, 412, 416, 418, 420, 422, 426, 428, 460, 462, 468, 480, 482, 486, 488, 490, 492, 496, 498, 602, 604, 608, 610, 612, 614, 618, 620, 622, 624, 628, 640, 642, 648, 680, 682, 684, 688, 690, 692, 694, 698, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 840, 842, 846, 848, 860, 862, 864, 868, 880, 882, 884, 886, 888, 890, 892, 894, 896, 898, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 940, 942, 946, 948, 960, 962, 964, 968, 980, 982, 984, 986, 988]\n assert candidate(digits = [2, 2, 2, 2, 2]) == [222]\n assert candidate(digits = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [112, 114, 122, 124, 132, 134, 142, 144, 152, 154, 212, 214, 224, 232, 234, 242, 244, 252, 254, 312, 314, 322, 324, 332, 334, 342, 344, 352, 354, 412, 414, 422, 424, 432, 434, 442, 452, 454, 512, 514, 522, 524, 532, 534, 542, 544, 552, 554]\n assert candidate(digits = [7, 7, 7, 7, 7, 8, 8, 8, 8, 8]) == [778, 788, 878, 888]\n assert candidate(digits = [0, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == [102, 110, 112, 120, 122, 130, 132, 202, 210, 212, 220, 222, 230, 232, 302, 310, 312, 320, 322, 330, 332]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == []\n assert candidate(digits = [5, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8]) == [200, 202, 204, 206, 208, 220, 222, 224, 226, 228, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 280, 282, 284, 286, 288, 400, 402, 404, 406, 408, 420, 422, 424, 426, 428, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 480, 482, 484, 486, 488, 500, 502, 504, 506, 508, 520, 522, 524, 526, 528, 540, 542, 544, 546, 548, 560, 562, 564, 566, 568, 580, 582, 584, 586, 588, 600, 602, 604, 606, 608, 620, 622, 624, 626, 628, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 666, 668, 680, 682, 684, 686, 688, 800, 802, 804, 806, 808, 820, 822, 824, 826, 828, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 880, 882, 884, 886, 888]\n", "comparison": "exact"}, "public_tests": ["[2,1,3,0]", "[2,2,8,8,2]", "[3,7,5]"], "hints": ["The range of possible answers includes all even numbers between 100 and 999 inclusive. Could you check each possible answer to see if it could be formed from the digits in the array?"], "metadata": {"canonical_parameter_names": ["digits"], "leetcode_dataset_entry_point": "Solution().findEvenNumbers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:40:53+00:00", "tests_total": 91, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "hash-table", "recursion", "sorting", "enumeration"]}, "language": "javascript", "interface": {"raw_signature": "var findEvenNumbers = function(digits) {", "container": null, "callable": "findEvenNumbers", "parameters": [{"name": "digits", "type": "number[]"}], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2097, "task_id": "valid-arrangement-of-pairs", "difficulty": "Hard", "problem_description": "You are given a 0-indexed 2D integer array pairs where pairs[i] = [start_i, end_i]. An arrangement of pairs is valid if for every index i where 1 <= i < pairs.length, we have end_{i-1} == start_i.\n\nReturn any valid arrangement of pairs.\n\nNote: The inputs will be generated such that there exists a valid arrangement of pairs.\n\nExample 1:\n\nInput: pairs = [[5,1],[4,5],[11,9],[9,4]]\nOutput: [[11,9],[9,4],[4,5],[5,1]]\nExplanation:\nThis is a valid arrangement since end_{i-1} always equals start_i.\nend_0 = 9 == 9 = start_1\nend_1 = 4 == 4 = start_2\nend_2 = 5 == 5 = start_3\n\nExample 2:\n\nInput: pairs = [[1,3],[3,2],[2,1]]\nOutput: [[1,3],[3,2],[2,1]]\nExplanation:\nThis is a valid arrangement since end_{i-1} always equals start_i.\nend_0 = 3 == 3 = start_1\nend_1 = 2 == 2 = start_2\nThe arrangements [[2,1],[1,3],[3,2]] and [[3,2],[2,1],[1,3]] are also valid.\n\nExample 3:\n\nInput: pairs = [[1,2],[1,3],[2,1]]\nOutput: [[1,2],[2,1],[1,3]]\nExplanation:\nThis is a valid arrangement since end_{i-1} always equals start_i.\nend_0 = 2 == 2 = start_1\nend_1 = 1 == 1 = start_2\n\nConstraints:\n\n- 1 <= pairs.length <= 10^5\n- pairs[i].length == 2\n- 0 <= start_i, end_i <= 10^9\n- start_i != end_i\n- No two pairs are exactly the same.\n- There exists a valid arrangement of pairs.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(pairs = [[0, 1], [1, 2], [2, 3], [3, 4]]) == [[0, 1], [1, 2], [2, 3], [3, 4]]\n assert candidate(pairs = [[0, 1], [1, 2], [2, 3], [3, 0]]) == [[0, 1], [1, 2], [2, 3], [3, 0]]\n assert candidate(pairs = [[1, 2], [1, 3], [2, 1]]) == [[1, 2], [2, 1], [1, 3]]\n assert candidate(pairs = [[10, 20], [20, 30], [30, 40], [40, 50]]) == [[10, 20], [20, 30], [30, 40], [40, 50]]\n assert candidate(pairs = [[1, 3], [3, 2], [2, 1]]) == [[1, 3], [3, 2], [2, 1]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 100]]) == [[100, 200], [200, 300], [300, 100]]\n assert candidate(pairs = [[10, 20], [20, 30], [30, 40], [40, 10]]) == [[10, 20], [20, 30], [30, 40], [40, 10]]\n assert candidate(pairs = [[5, 1], [4, 5], [11, 9], [9, 4]]) == [[11, 9], [9, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 1]]) == [[1, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 1]]\n assert candidate(pairs = [[7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7]]) == [[7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100]]) == [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [3, 5], [5, 2], [2, 4], [4, 1]]) == [[1, 3], [3, 5], [5, 2], [2, 4], [4, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [3, 5]]) == [[1, 3], [3, 5], [5, 1], [1, 2], [2, 3], [3, 4], [4, 5]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 11], [11, 12], [12, 13], [13, 1]]) == [[1, 11], [11, 12], [12, 13], [13, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [1, 10], [10, 11], [11, 1]]) == [[1, 10], [10, 11], [11, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 1]]) == [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7]]) == [[1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]) == [[1, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [3, 5]]) == [[1, 3], [3, 5], [5, 1], [1, 2], [2, 3], [3, 4], [4, 5]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1]]\n assert candidate(pairs = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1]]) == [[1, 5], [5, 1], [1, 4], [4, 1], [1, 3], [3, 1], [1, 2], [2, 1]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 1], [1, 60], [60, 70], [70, 80], [80, 1]]) == [[1, 60], [60, 70], [70, 80], [80, 1], [1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 1]]\n assert candidate(pairs = [[5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5]]) == [[5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 100], [100, 400], [400, 500], [500, 100]]) == [[100, 400], [400, 500], [500, 100], [100, 200], [200, 300], [300, 100]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [2, 7], [7, 8], [8, 9], [9, 10], [10, 2]]) == [[1, 2], [2, 7], [7, 8], [8, 9], [9, 10], [10, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]\n assert candidate(pairs = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 1], [1, 13], [13, 2]]) == [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 1], [1, 13], [13, 2]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 1], [1, 3], [3, 2], [2, 4], [4, 3], [3, 1], [1, 4], [4, 2], [2, 1]]) == [[1, 4], [4, 2], [2, 1], [1, 3], [3, 1], [1, 2], [2, 4], [4, 3], [3, 2], [2, 3], [3, 4], [4, 1]]\n assert candidate(pairs = [[1, 2], [3, 1], [2, 3], [4, 2], [3, 5], [5, 4], [4, 1]]) == [[3, 5], [5, 4], [4, 2], [4, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [7, 8], [8, 9], [9, 10], [10, 7]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]\n assert candidate(pairs = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 10], [10, 30], [30, 50], [50, 20], [20, 40], [40, 10]]) == [[10, 30], [30, 50], [50, 20], [20, 40], [40, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 10]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [1, 10], [10, 11], [11, 1], [12, 13], [13, 14], [14, 12]]) == [[1, 10], [10, 11], [11, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 999], [999, 2], [2, 998], [998, 3], [3, 997], [997, 4], [4, 996], [996, 5], [5, 995], [995, 1]]) == [[1, 999], [999, 2], [2, 998], [998, 3], [3, 997], [997, 4], [4, 996], [996, 5], [5, 995], [995, 1]]\n assert candidate(pairs = [[1, 9], [9, 7], [7, 3], [3, 5], [5, 1], [1, 8], [8, 6], [6, 2], [2, 4], [4, 1]]) == [[1, 8], [8, 6], [6, 2], [2, 4], [4, 1], [1, 9], [9, 7], [7, 3], [3, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == [[1, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 4]]) == [[1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1000000, 2000000], [2000000, 3000000], [3000000, 1000000], [500000, 1000000]]) == [[500000, 1000000], [1000000, 2000000], [2000000, 3000000], [3000000, 1000000]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 100]]) == [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 100]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 7], [7, 4], [8, 9], [9, 10], [10, 8]]) == [[1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 4]]) == [[1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1000, 2000], [2000, 3000], [3000, 1000], [1000, 4000], [4000, 5000], [5000, 6000], [6000, 1000]]) == [[1000, 4000], [4000, 5000], [5000, 6000], [6000, 1000], [1000, 2000], [2000, 3000], [3000, 1000]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]\n assert candidate(pairs = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 5]]) == [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 5]]\n assert candidate(pairs = [[1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 6], [6, 7], [7, 8], [8, 1], [1, 9], [9, 10], [10, 1]]) == [[1, 9], [9, 10], [10, 1], [1, 6], [6, 7], [7, 8], [8, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[5, 6], [6, 5], [5, 7], [7, 5], [5, 8], [8, 5], [5, 9], [9, 5], [5, 10], [10, 5]]) == [[5, 10], [10, 5], [5, 9], [9, 5], [5, 8], [8, 5], [5, 7], [7, 5], [5, 6], [6, 5]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 1], [1, 20], [20, 3], [3, 21], [21, 1]]) == [[1, 20], [20, 3], [3, 21], [21, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 1]]\n assert candidate(pairs = [[7, 8], [8, 9], [9, 10], [10, 11], [11, 7], [7, 12], [12, 8]]) == [[7, 12], [12, 8], [8, 9], [9, 10], [10, 11], [11, 7], [7, 8]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 100]]) == [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 100]]\n assert candidate(pairs = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 5]]) == [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 5]]\n assert candidate(pairs = [[7, 8], [8, 9], [9, 10], [10, 11], [11, 7], [7, 9], [9, 11], [11, 8]]) == [[7, 9], [9, 11], [11, 8], [8, 9], [9, 10], [10, 11], [11, 7], [7, 8]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 11], [14, 15], [15, 16], [16, 14], [17, 18], [18, 19], [19, 20], [20, 17]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 9], [9, 10], [10, 11], [11, 12], [12, 1], [1, 13], [13, 14], [14, 15], [15, 1], [1, 16], [16, 17], [17, 18], [18, 1]]) == [[1, 16], [16, 17], [17, 18], [18, 1], [1, 13], [13, 14], [14, 15], [15, 1], [1, 9], [9, 10], [10, 11], [11, 12], [12, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]]\n assert candidate(pairs = [[1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 61], [61, 71], [71, 81], [81, 91], [91, 1]]) == [[1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 61], [61, 71], [71, 81], [81, 91], [91, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 10], [10, 2]]) == [[1, 10], [10, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 2]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100], [100, 600], [600, 700], [700, 800], [800, 900], [900, 100]]) == [[100, 600], [600, 700], [700, 800], [800, 900], [900, 100], [100, 200], [200, 300], [300, 400], [400, 500], [500, 100]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 1], [60, 70], [70, 80], [80, 90], [90, 100], [100, 60]]) == [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 1]]\n assert candidate(pairs = [[5, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5]]) == [[5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5], [5, 1], [1, 2], [2, 3], [3, 4], [4, 5]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [1, 4], [4, 7], [7, 1]]) == [[1, 4], [4, 5], [5, 6], [6, 4], [4, 7], [7, 8], [8, 9], [9, 7], [7, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 1]]) == [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 1]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 1]]) == [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 1]]\n assert candidate(pairs = [[1, 1000000000], [1000000000, 999999999], [999999999, 888888888], [888888888, 1]]) == [[1, 1000000000], [1000000000, 999999999], [999999999, 888888888], [888888888, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 10], [10, 11], [11, 12], [12, 1]]) == [[1, 10], [10, 11], [11, 12], [12, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 11], [14, 15], [15, 16], [16, 14], [17, 18], [18, 19], [19, 20], [20, 17], [21, 22], [22, 23], [23, 21]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [1, 4], [4, 5], [5, 1], [1, 6], [6, 7], [7, 1]]) == [[1, 6], [6, 7], [7, 1], [1, 4], [4, 5], [5, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 3]]) == [[3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 3]]\n assert candidate(pairs = [[11, 22], [22, 33], [33, 44], [44, 55], [55, 66], [66, 77], [77, 88], [88, 99], [99, 11]]) == [[11, 22], [22, 33], [33, 44], [44, 55], [55, 66], [66, 77], [77, 88], [88, 99], [99, 11]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100], [100, 300], [300, 500], [500, 200]]) == [[100, 300], [300, 500], [500, 200], [200, 300], [300, 400], [400, 500], [500, 100], [100, 200]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 1], [1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 61], [61, 71], [71, 81], [81, 91], [91, 1]]) == [[1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 61], [61, 71], [71, 81], [81, 91], [91, 1], [1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 1], [5, 6], [6, 7], [7, 5]]) == [[1, 2], [2, 3], [3, 4], [4, 1]]\n assert candidate(pairs = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1], [1, 7], [7, 1], [1, 8], [8, 1], [1, 9], [9, 1], [1, 10], [10, 1]]) == [[1, 10], [10, 1], [1, 9], [9, 1], [1, 8], [8, 1], [1, 7], [7, 1], [1, 6], [6, 1], [1, 5], [5, 1], [1, 4], [4, 1], [1, 3], [3, 1], [1, 2], [2, 1]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [1000, 100]]) == [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [1000, 100]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 1], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 4]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 4], [4, 1]]\n assert candidate(pairs = [[123, 456], [456, 789], [789, 101], [101, 112], [112, 234], [234, 345], [345, 123]]) == [[123, 456], [456, 789], [789, 101], [101, 112], [112, 234], [234, 345], [345, 123]]\n", "comparison": "exact"}, "public_tests": ["[[5,1],[4,5],[11,9],[9,4]]", "[[1,3],[3,2],[2,1]]", "[[1,2],[1,3],[2,1]]"], "hints": ["Could you convert this into a graph problem?", "Consider the pairs as edges and each number as a node.", "We have to find an Eulerian path of this graph. Hierholzer’s algorithm can be used."], "metadata": {"canonical_parameter_names": ["pairs"], "leetcode_dataset_entry_point": "Solution().validArrangement", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:00+00:00", "tests_total": 79, "tests_dropped": 0, "flags": ["multiple_answers"], "topic_tags": ["array", "depth-first-search", "graph", "eulerian-circuit", "eulerian-path", "semi-eulerian-graph"]}, "language": "javascript", "interface": {"raw_signature": "var validArrangement = function(pairs) {", "container": null, "callable": "validArrangement", "parameters": [{"name": "pairs", "type": "number[][]"}], "return_type": "number[][]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2099, "task_id": "find-subsequence-of-length-k-with-the-largest-sum", "difficulty": "Easy", "problem_description": "You are given an integer array nums and an integer k. You want to find a subsequence of nums of length k that has the largest sum.\n\nReturn any such subsequence as an integer array of length k.\n\nA subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.\n\nExample 1:\n\nInput: nums = [2,1,3,3], k = 2\nOutput: [3,3]\nExplanation:\nThe subsequence has the largest sum of 3 + 3 = 6.\n\nExample 2:\n\nInput: nums = [-1,-2,3,4], k = 3\nOutput: [-1,3,4]\nExplanation:\nThe subsequence has the largest sum of -1 + 3 + 4 = 6.\n\nExample 3:\n\nInput: nums = [3,4,3,3], k = 2\nOutput: [3,4]\nExplanation:\nThe subsequence has the largest sum of 3 + 4 = 7.\nAnother possible subsequence is [4, 3].\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- -10^5 <= nums[i] <= 10^5\n- 1 <= k <= nums.length\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 3, 1, 2, 4],k = 5) == [5, 3, 1, 2, 4]\n assert candidate(nums = [10, 10, 10, 10, 10],k = 3) == [10, 10, 10]\n assert candidate(nums = [0, 0, 0, 0],k = 2) == [0, 0]\n assert candidate(nums = [-1, -2, 3, 4],k = 3) == [-1, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == [3, 4, 5]\n assert candidate(nums = [5, 1, 2, 3, 4],k = 3) == [5, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == [6, 7, 8, 9, 10]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [-1, -2, -3, -4],k = 2) == [-1, -2]\n assert candidate(nums = [-1, -1, -1, -1, -1],k = 3) == [-1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500],k = 4) == [200, 300, 400, 500]\n assert candidate(nums = [1],k = 1) == [1]\n assert candidate(nums = [2, 1, 3, 3],k = 2) == [3, 3]\n assert candidate(nums = [-10, -20, -30, -40],k = 2) == [-10, -20]\n assert candidate(nums = [5, 4, 3, 2, 1],k = 4) == [5, 4, 3, 2]\n assert candidate(nums = [100000, -100000, 50000, -50000, 0],k = 2) == [100000, 50000]\n assert candidate(nums = [10, -2, 0, 5],k = 2) == [10, 5]\n assert candidate(nums = [5, 1, 2, 4, 3],k = 3) == [5, 4, 3]\n assert candidate(nums = [3, 4, 3, 3],k = 2) == [4, 3]\n assert candidate(nums = [-5, -4, -3, -2, -1],k = 2) == [-2, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 10) == [16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 15) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],k = 10) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 3) == [100, 90, 80]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 7) == [50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 3) == [-1, -2, -3]\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],k = 4) == [300, 500, 700, 900]\n assert candidate(nums = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50],k = 7) == [10, 20, 30, 40, 50, -10, -20]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],k = 7) == [-1, -2, -3, -4, -5, -6, -7]\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],k = 6) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [100000, -50000, 100000, -50000, 100000],k = 3) == [100000, 100000, 100000]\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100],k = 5) == [10, 30, 50, 70, 90]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 15) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],k = 3) == [-1, -2, -3]\n assert candidate(nums = [100, 200, 300, 400, 500],k = 1) == [500]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50],k = 5) == [10, 20, 30, 40, 50]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130],k = 7) == [70, 80, 90, 100, 110, 120, 130]\n assert candidate(nums = [-10, 100, -20, 200, -30, 300, -40, 400, -50, 500, -60, 600, -70, 700, -80, 800],k = 8) == [100, 200, 300, 400, 500, 600, 700, 800]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [10, -1, 2, 9, 3, 8, 4, 7, 5, 6],k = 5) == [10, 9, 8, 7, 6]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 15) == [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],k = 3) == [99999, 99998, 99997]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 3) == [100, 90, 80]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k = 8) == [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],k = 7) == [10, 9, 8, 7, 6, 5, 4]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == [1, 1, 1]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100],k = 10) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, -1, 2, -3, 4, -5, 6, -7, 8, -9],k = 5) == [10, 2, 4, 6, 8]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90],k = 15) == [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == [9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],k = 5) == [100, 200, 300, 400, 500]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 15) == [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, -1, -2, -3, -4, -5]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 4) == [-1, -2, -3, -4]\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 1100, -1200, 1300],k = 7) == [100, 300, 500, 700, 900, 1100, 1300]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == [6, 6, 7, 7, 8, 8, 9, 9, 10, 10]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 4) == [50, 50, 50, 50]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == [60, 70, 80, 90, 100]\n assert candidate(nums = [100000, -100000, 50000, -50000, 0, 25000, -25000, 75000, -75000],k = 3) == [100000, 50000, 75000]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],k = 10) == [7, 6, 9, 8, 11, 10, 13, 12, 15, 14]\n assert candidate(nums = [-100, -200, -300, -400, -500],k = 3) == [-100, -200, -300]\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],k = 8) == [1000, 900, 800, 700, 600, 500, 400, 300]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],k = 5) == [1, 3, 5, 7, 9]\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 3) == [-10, -20, -30]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 10) == [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 6) == [1, -1, 2, 3, 4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 10) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 6) == [9, 8, 7, 6, 5, 4]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == [0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == [9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 10) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [10000, -10000, 20000, -20000, 30000, -30000, 40000, -40000],k = 4) == [10000, 20000, 30000, 40000]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 3) == [-1, -2, -3]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [0, 0, 0, 0, 0]\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8, 10],k = 5) == [9, 6, 7, 8, 10]\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500],k = 10) == [300, 400, 500, 300, 400, 500, 200, 300, 400, 500]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 20) == [21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 6) == [25, 30, 35, 40, 45, 50]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110],k = 5) == [-10, -20, -30, -40, -50]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == [15, 14, 13, 12, 11, 10, 9, 8]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1],k = 10) == [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 8) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [-10, -20, -30, -40, -50, 100, 200],k = 3) == [-10, 100, 200]\n", "comparison": "exact"}, "public_tests": ["[2,1,3,3]\n2", "[-1,-2,3,4]\n3", "[3,4,3,3]\n2"], "hints": ["From a greedy perspective, what k elements should you pick?", "Could you sort the array while maintaining the index?"], "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maxSubsequence", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:05+00:00", "tests_total": 99, "tests_dropped": 1, "flags": ["multiple_answers"], "topic_tags": ["array", "hash-table", "sorting", "heap-priority-queue"]}, "language": "javascript", "interface": {"raw_signature": "var maxSubsequence = function(nums, k) {", "container": null, "callable": "maxSubsequence", "parameters": [{"name": "nums", "type": "number[]"}, {"name": "k", "type": "number"}], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2100, "task_id": "find-good-days-to-rob-the-bank", "difficulty": "Medium", "problem_description": "You and a gang of thieves are planning on robbing a bank. You are given a 0-indexed integer array security, where security[i] is the number of guards on duty on the i^th day. The days are numbered starting from 0. You are also given an integer time.\n\nThe i^th day is a good day to rob the bank if:\n\n- There are at least time days before and after the i^th day,\n- The number of guards at the bank for the time days before i are non-increasing, and\n- The number of guards at the bank for the time days after i are non-decreasing.\n\nMore formally, this means day i is a good day to rob the bank if and only if security[i - time] >= security[i - time + 1] >= ... >= security[i] <= ... <= security[i + time - 1] <= security[i + time].\n\nReturn a list of all days (0-indexed) that are good days to rob the bank. The order that the days are returned in does not matter.\n\nExample 1:\n\nInput: security = [5,3,3,3,5,6,2], time = 2\nOutput: [2,3]\nExplanation:\nOn day 2, we have security[0] >= security[1] >= security[2] <= security[3] <= security[4].\nOn day 3, we have security[1] >= security[2] >= security[3] <= security[4] <= security[5].\nNo other days satisfy this condition, so days 2 and 3 are the only good days to rob the bank.\n\nExample 2:\n\nInput: security = [1,1,1,1,1], time = 0\nOutput: [0,1,2,3,4]\nExplanation:\nSince time equals 0, every day is a good day to rob the bank, so return every day.\n\nExample 3:\n\nInput: security = [1,2,3,4,5,6], time = 2\nOutput: []\nExplanation:\nNo day has 2 days before it that have a non-increasing number of guards.\nThus, no day is a good day to rob the bank, so return an empty list.\n\nConstraints:\n\n- 1 <= security.length <= 10^5\n- 0 <= security[i], time <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(security = [3, 3, 5, 5, 5, 5, 2, 2, 2, 3],time = 2) == [6, 7]\n assert candidate(security = [1, 1, 1, 1, 1],time = 0) == [0, 1, 2, 3, 4]\n assert candidate(security = [1, 2, 2, 3, 3, 4, 5, 5, 6, 6],time = 1) == [2, 4, 7]\n assert candidate(security = [6, 5, 4, 3, 2, 1],time = 2) == []\n assert candidate(security = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],time = 1) == [2, 4, 6, 8]\n assert candidate(security = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],time = 0) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(security = [1, 2, 2, 3, 3, 4],time = 1) == [2, 4]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],time = 3) == []\n assert candidate(security = [1, 2, 2, 3, 3, 4, 5],time = 1) == [2, 4]\n assert candidate(security = [3, 3, 5, 5, 5, 5, 2, 2, 1, 1],time = 2) == []\n assert candidate(security = [1, 1, 1, 2, 2, 2, 3, 3, 3],time = 2) == [2, 5]\n assert candidate(security = [100, 90, 80, 70, 60, 50, 60, 70, 80, 90, 100],time = 4) == [5]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3],time = 3) == [3]\n assert candidate(security = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],time = 4) == [4, 5]\n assert candidate(security = [1],time = 0) == [0]\n assert candidate(security = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],time = 2) == []\n assert candidate(security = [3, 3, 5, 5, 5, 5, 4, 4, 4, 3],time = 3) == []\n assert candidate(security = [1, 2, 3, 4, 5, 6],time = 2) == []\n assert candidate(security = [1, 2, 3, 3, 3, 3, 2, 2, 1],time = 2) == []\n assert candidate(security = [5, 3, 3, 3, 5, 6, 2],time = 2) == [2, 3]\n assert candidate(security = [1, 2, 3, 2, 1, 0, 1, 0, 1, 2, 3],time = 1) == [5, 7]\n assert candidate(security = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],time = 2) == [5]\n assert candidate(security = [1, 2, 2, 3, 4, 5, 5, 4, 3, 2, 1],time = 3) == []\n assert candidate(security = [6, 5, 4, 3, 2, 1],time = 3) == []\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],time = 3) == []\n assert candidate(security = [1, 2],time = 1) == []\n assert candidate(security = [2, 1],time = 1) == []\n assert candidate(security = [1, 3, 3, 3, 3, 2, 2, 2, 2],time = 2) == [5, 6]\n assert candidate(security = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],time = 5) == [23]\n assert candidate(security = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],time = 2) == [2, 6, 10, 14, 18, 22, 26]\n assert candidate(security = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],time = 10) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7],time = 2) == [8]\n assert candidate(security = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],time = 10) == [10, 11, 12, 13, 14, 15]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = 5) == [10]\n assert candidate(security = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],time = 0) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],time = 3) == [11]\n assert candidate(security = [5, 3, 3, 3, 3, 5, 6, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1],time = 3) == [3, 11, 12, 13]\n assert candidate(security = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1],time = 2) == [3, 6, 9, 13, 16, 19]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5],time = 2) == []\n assert candidate(security = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],time = 10) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(security = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12],time = 2) == []\n assert candidate(security = [1, 2, 3, 2, 1, 0, 1, 0, 1, 2, 3, 2, 1, 0, 1],time = 2) == []\n assert candidate(security = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5],time = 2) == [8, 16]\n assert candidate(security = [7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7],time = 3) == [4, 8, 9, 10, 11, 15]\n assert candidate(security = [1, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2],time = 1) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6],time = 3) == [11]\n assert candidate(security = [1, 3, 2, 2, 2, 1, 2, 2, 2, 3, 1, 1, 1],time = 1) == [2, 3, 5, 7, 8, 10, 11]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1],time = 4) == [8, 9, 17]\n assert candidate(security = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],time = 2) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]\n assert candidate(security = [1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2],time = 2) == [4, 8, 12]\n assert candidate(security = [10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10],time = 4) == [12]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 4) == [4, 5]\n assert candidate(security = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],time = 5) == [10]\n assert candidate(security = [5, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4],time = 5) == []\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],time = 6) == [10, 11, 12, 13, 14]\n assert candidate(security = [5, 3, 3, 3, 5, 6, 2, 2, 2, 1, 1, 1, 2, 2, 2],time = 3) == [9, 10, 11]\n assert candidate(security = [1, 2, 2, 1, 0, 0, 1, 1, 2, 2],time = 1) == [4, 5, 7]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],time = 4) == [19]\n assert candidate(security = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],time = 4) == [9]\n assert candidate(security = [5, 3, 3, 3, 5, 6, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],time = 2) == [2, 3, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 5) == [5, 6, 7, 8, 9, 10, 11]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],time = 5) == []\n assert candidate(security = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0],time = 4) == []\n assert candidate(security = [2, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 2, 1, 1, 2, 2],time = 2) == [5, 6, 12, 13]\n assert candidate(security = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],time = 3) == [4]\n assert candidate(security = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],time = 2) == []\n assert candidate(security = [10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],time = 4) == []\n assert candidate(security = [1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 10, 11, 12, 11, 12, 13],time = 4) == []\n assert candidate(security = [3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],time = 2) == [2, 5, 6, 7, 8, 9, 12]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5],time = 3) == [8, 16]\n assert candidate(security = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],time = 1) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],time = 3) == [10]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],time = 4) == [10]\n assert candidate(security = [5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5],time = 4) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5],time = 2) == []\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6],time = 8) == [10]\n assert candidate(security = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],time = 7) == [7, 8, 9]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = 4) == [10]\n assert candidate(security = [3, 2, 1, 2, 1, 0, 1, 0, 1, 2, 3, 2, 1, 2, 1, 0, 1, 0, 1, 2],time = 2) == []\n assert candidate(security = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6],time = 3) == [11, 23]\n assert candidate(security = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],time = 3) == [5]\n assert candidate(security = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 1],time = 3) == []\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 5) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(security = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],time = 3) == []\n assert candidate(security = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],time = 5) == [10, 11]\n assert candidate(security = [9, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1],time = 4) == [4]\n assert candidate(security = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1],time = 2) == [4, 5, 8, 9, 12, 13, 16, 17, 20, 21]\n assert candidate(security = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5],time = 2) == [2, 5, 6, 7, 8, 9, 12, 13, 14, 17, 18, 19, 22, 23, 24, 27]\n assert candidate(security = [3, 3, 5, 5, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],time = 3) == [5]\n assert candidate(security = [3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0],time = 3) == [4, 8, 12, 13]\n assert candidate(security = [1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2],time = 2) == [4, 5, 6, 10, 11, 12, 16, 17, 18]\n assert candidate(security = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11],time = 3) == []\n assert candidate(security = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = 4) == [5, 20]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],time = 7) == [19]\n assert candidate(security = [1, 2, 3, 2, 1, 2, 1, 2, 3, 4, 3, 2, 1, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1],time = 3) == []\n assert candidate(security = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],time = 3) == [5]\n assert candidate(security = [1, 3, 2, 3, 1, 2, 3, 2, 1, 2, 1, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1, 3, 2, 1],time = 2) == [13]\n assert candidate(security = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],time = 5) == [5]\n assert candidate(security = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],time = 2) == [2, 3, 4, 5, 6, 7]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 5, 5, 6, 7, 8, 9, 10],time = 3) == [5, 6, 7]\n assert candidate(security = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],time = 5) == [5, 6, 7, 8, 9, 10]\n assert candidate(security = [8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8],time = 2) == [2, 5, 6, 7, 8, 9, 12]\n assert candidate(security = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],time = 10) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46]\n assert candidate(security = [1, 3, 2, 3, 2, 1, 2, 3, 2, 1],time = 1) == [2, 5]\n assert candidate(security = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],time = 5) == []\n assert candidate(security = [1, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 5, 6, 7, 8, 9],time = 2) == [5, 11]\n assert candidate(security = [8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],time = 6) == [7]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 12) == [12, 13]\n assert candidate(security = [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],time = 7) == []\n assert candidate(security = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],time = 2) == [3, 4, 5, 6, 7, 8, 9]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10],time = 2) == [5]\n assert candidate(security = [5, 5, 4, 4, 4, 5, 6, 7, 8, 8],time = 2) == [2, 3, 4]\n assert candidate(security = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],time = 2) == [10, 11]\n assert candidate(security = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = 3) == [4]\n assert candidate(security = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1],time = 3) == []\n assert candidate(security = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],time = 5) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]\n assert candidate(security = [3, 3, 5, 5, 5, 5, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 1, 1, 1],time = 3) == [11]\n assert candidate(security = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3],time = 2) == [4, 8, 12]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 5) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]\n assert candidate(security = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],time = 2) == []\n assert candidate(security = [1, 3, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],time = 2) == []\n assert candidate(security = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],time = 5) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(security = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1],time = 1) == [1, 4, 5, 8, 9, 12, 13, 16, 17, 20]\n", "comparison": "exact"}, "public_tests": ["[5,3,3,3,5,6,2]\n2", "[1,1,1,1,1]\n0", "[1,2,3,4,5,6]\n2"], "hints": ["The trivial solution is to check the time days before and after each day. There are a lot of repeated operations using this solution. How could we optimize this solution?", "We can use precomputation to make the solution faster.", "Use an array to store the number of days before the i^th day that is non-increasing, and another array to store the number of days after the i^th day that is non-decreasing."], "metadata": {"canonical_parameter_names": ["security", "time"], "leetcode_dataset_entry_point": "Solution().goodDaysToRobBank", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:07+00:00", "tests_total": 123, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "dynamic-programming", "prefix-sum"]}, "language": "javascript", "interface": {"raw_signature": "var goodDaysToRobBank = function(security, time) {", "container": null, "callable": "goodDaysToRobBank", "parameters": [{"name": "security", "type": "number[]"}, {"name": "time", "type": "number"}], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2101, "task_id": "detonate-the-maximum-bombs", "difficulty": "Medium", "problem_description": "You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the center as the location of the bomb.\n\nThe bombs are represented by a 0-indexed 2D integer array bombs where bombs[i] = [x_i, y_i, r_i]. x_i and y_i denote the X-coordinate and Y-coordinate of the location of the i^th bomb, whereas r_i denotes the radius of its range.\n\nYou may choose to detonate a single bomb. When a bomb is detonated, it will detonate all bombs that lie in its range. These bombs will further detonate the bombs that lie in their ranges.\n\nGiven the list of bombs, return the maximum number of bombs that can be detonated if you are allowed to detonate only one bomb.\n\nExample 1:\n\nInput: bombs = [[2,1,3],[6,1,4]]\nOutput: 2\nExplanation:\nThe above figure shows the positions and ranges of the 2 bombs.\nIf we detonate the left bomb, the right bomb will not be affected.\nBut if we detonate the right bomb, both bombs will be detonated.\nSo the maximum bombs that can be detonated is max(1, 2) = 2.\n\nExample 2:\n\nInput: bombs = [[1,1,5],[10,10,5]]\nOutput: 1\nExplanation:\nDetonating either bomb will not detonate the other bomb, so the maximum number of bombs that can be detonated is 1.\n\nExample 3:\n\nInput: bombs = [[1,2,3],[2,3,1],[3,4,2],[4,5,3],[5,6,4]]\nOutput: 5\nExplanation:\nThe best bomb to detonate is bomb 0 because:\n- Bomb 0 detonates bombs 1 and 2. The red circle denotes the range of bomb 0.\n- Bomb 2 detonates bomb 3. The blue circle denotes the range of bomb 2.\n- Bomb 3 detonates bomb 4. The green circle denotes the range of bomb 3.\nThus all 5 bombs are detonated.\n\nConstraints:\n\n- 1 <= bombs.length <= 100\n- bombs[i].length == 3\n- 1 <= x_i, y_i, r_i <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(bombs = [[10, 10, 5], [15, 15, 5], [20, 20, 5]]) == 1\n assert candidate(bombs = [[1, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 1], [3, 3, 1]]) == 1\n assert candidate(bombs = [[1, 1, 100], [1, 1, 50], [1, 1, 25]]) == 3\n assert candidate(bombs = [[1, 1, 10], [10, 10, 10], [5, 5, 5]]) == 2\n assert candidate(bombs = [[1, 1, 10], [10, 10, 1], [5, 5, 5]]) == 2\n assert candidate(bombs = [[1, 1, 5], [10, 10, 5]]) == 1\n assert candidate(bombs = [[1, 2, 3], [2, 3, 1], [3, 4, 2], [4, 5, 3], [5, 6, 4]]) == 5\n assert candidate(bombs = [[5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1]]) == 1\n assert candidate(bombs = [[100, 100, 1], [101, 101, 1], [102, 102, 1]]) == 1\n assert candidate(bombs = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2]]) == 4\n assert candidate(bombs = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 3\n assert candidate(bombs = [[2, 1, 3], [6, 1, 4]]) == 2\n assert candidate(bombs = [[1, 1, 3], [2, 2, 3], [3, 3, 3], [4, 4, 3]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1]]) == 1\n assert candidate(bombs = [[5, 5, 3], [6, 6, 1], [7, 7, 4]]) == 3\n assert candidate(bombs = [[5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8]]) == 4\n assert candidate(bombs = [[10, 10, 10], [20, 20, 10], [30, 30, 10]]) == 1\n assert candidate(bombs = [[10, 10, 1], [20, 10, 1], [30, 10, 1], [40, 10, 1], [50, 10, 1], [60, 10, 1], [70, 10, 1], [80, 10, 1], [90, 10, 1], [100, 10, 1]]) == 1\n assert candidate(bombs = [[100, 100, 10], [100, 110, 10], [100, 120, 10], [110, 100, 10], [110, 110, 10], [110, 120, 10], [120, 100, 10], [120, 110, 10], [120, 120, 10]]) == 9\n assert candidate(bombs = [[10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5], [35, 35, 5], [40, 40, 5]]) == 1\n assert candidate(bombs = [[50, 50, 10], [60, 60, 20], [70, 70, 30], [80, 80, 40], [90, 90, 50]]) == 5\n assert candidate(bombs = [[10, 10, 3], [10, 13, 3], [13, 10, 3], [13, 13, 3], [16, 16, 3], [16, 19, 3], [19, 16, 3], [19, 19, 3]]) == 4\n assert candidate(bombs = [[1, 1, 10], [1, 10, 10], [10, 1, 10], [10, 10, 10], [15, 15, 15], [15, 5, 15], [5, 15, 15], [20, 20, 5]]) == 8\n assert candidate(bombs = [[50, 50, 5], [55, 50, 5], [60, 50, 5], [65, 50, 5], [70, 50, 5], [75, 50, 5], [80, 50, 5], [85, 50, 5], [90, 50, 5], [95, 50, 5], [100, 50, 5], [105, 50, 5], [110, 50, 5], [115, 50, 5], [120, 50, 5], [125, 50, 5], [130, 50, 5], [135, 50, 5], [140, 50, 5], [145, 50, 5]]) == 20\n assert candidate(bombs = [[100, 100, 10], [110, 100, 10], [120, 100, 10], [130, 100, 10], [140, 100, 10], [150, 100, 10], [160, 100, 10], [170, 100, 10], [180, 100, 10]]) == 9\n assert candidate(bombs = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1]]) == 1\n assert candidate(bombs = [[50, 50, 5], [60, 50, 5], [70, 50, 5], [80, 50, 5], [50, 60, 5], [50, 70, 5], [50, 80, 5], [50, 90, 5], [50, 100, 5], [60, 60, 15]]) == 6\n assert candidate(bombs = [[100, 100, 50], [200, 100, 50], [100, 200, 50], [200, 200, 50], [150, 150, 100]]) == 5\n assert candidate(bombs = [[10, 10, 1], [20, 20, 1], [30, 30, 1], [40, 40, 1], [50, 50, 1], [60, 60, 1], [70, 70, 1], [80, 80, 1], [90, 90, 1], [100, 100, 100]]) == 8\n assert candidate(bombs = [[5, 5, 5], [5, 15, 5], [15, 5, 5], [15, 15, 5], [10, 10, 20]]) == 5\n assert candidate(bombs = [[1, 1, 5], [2, 2, 10], [3, 3, 2], [4, 4, 8], [5, 5, 1]]) == 5\n assert candidate(bombs = [[1, 1, 100], [1, 1, 100], [1, 1, 100], [1, 1, 100], [1, 1, 100]]) == 5\n assert candidate(bombs = [[50, 50, 15], [60, 50, 20], [70, 50, 10], [50, 60, 25], [50, 70, 12], [50, 80, 5]]) == 6\n assert candidate(bombs = [[1, 1, 10], [10, 1, 10], [1, 10, 10], [10, 10, 10], [5, 5, 5], [15, 15, 15]]) == 6\n assert candidate(bombs = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9], [1, 10, 10]]) == 10\n assert candidate(bombs = [[1, 1, 10], [20, 20, 10], [30, 30, 10], [40, 40, 10], [50, 50, 10], [60, 60, 10]]) == 1\n assert candidate(bombs = [[100, 100, 50], [200, 200, 50], [300, 300, 50], [100, 200, 60], [200, 300, 70]]) == 1\n assert candidate(bombs = [[10, 10, 1], [15, 15, 2], [20, 20, 3], [25, 25, 4], [30, 30, 5]]) == 1\n assert candidate(bombs = [[5, 5, 1], [5, 6, 1], [5, 7, 1], [5, 8, 1], [5, 9, 1]]) == 5\n assert candidate(bombs = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40], [5, 5, 50], [6, 6, 60]]) == 6\n assert candidate(bombs = [[5, 5, 20], [10, 5, 20], [15, 5, 20], [20, 5, 20], [25, 5, 20], [30, 5, 20], [35, 5, 20], [40, 5, 20], [45, 5, 20], [50, 5, 20]]) == 10\n assert candidate(bombs = [[1, 1, 100], [200, 200, 100], [400, 400, 100], [600, 600, 100], [800, 800, 100], [1000, 1000, 100], [1200, 1200, 100], [1400, 1400, 100], [1600, 1600, 100], [1800, 1800, 100]]) == 1\n assert candidate(bombs = [[10, 10, 15], [20, 20, 15], [30, 30, 15], [40, 40, 15], [50, 50, 15], [60, 60, 15], [70, 70, 15], [80, 80, 15], [90, 90, 15]]) == 9\n assert candidate(bombs = [[10, 10, 15], [20, 20, 15], [30, 30, 15], [40, 40, 15], [50, 50, 15], [60, 60, 15], [70, 70, 15]]) == 7\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]]) == 10\n assert candidate(bombs = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10]]) == 8\n assert candidate(bombs = [[100, 100, 100], [200, 100, 100], [300, 100, 100], [400, 100, 100], [500, 100, 100], [600, 100, 100], [700, 100, 100], [800, 100, 100], [900, 100, 100]]) == 9\n assert candidate(bombs = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1]]) == 1\n assert candidate(bombs = [[10, 10, 5], [15, 10, 5], [20, 10, 5], [25, 10, 5], [30, 10, 5], [35, 10, 5], [40, 10, 5], [45, 10, 5]]) == 8\n assert candidate(bombs = [[1, 1, 100], [1, 101, 100], [101, 101, 100], [101, 1, 100], [51, 51, 100], [51, 1, 100], [1, 51, 100], [101, 51, 100], [51, 101, 100]]) == 9\n assert candidate(bombs = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2], [5, 5, 2], [6, 6, 2]]) == 6\n assert candidate(bombs = [[10, 10, 20], [30, 30, 20], [50, 50, 20], [70, 70, 20], [90, 90, 20], [110, 110, 20], [130, 130, 20], [150, 150, 20], [170, 170, 20], [190, 190, 20], [210, 210, 20], [230, 230, 20], [250, 250, 20], [270, 270, 20], [290, 290, 20]]) == 1\n assert candidate(bombs = [[5, 5, 2], [10, 5, 2], [15, 5, 2], [20, 5, 2], [25, 5, 2], [30, 5, 2], [35, 5, 2], [40, 5, 2], [45, 5, 2], [50, 5, 2], [55, 5, 2]]) == 1\n assert candidate(bombs = [[10, 10, 15], [20, 20, 25], [30, 30, 35], [40, 40, 45], [50, 50, 55]]) == 5\n assert candidate(bombs = [[100, 100, 100], [200, 200, 50], [300, 300, 25], [400, 400, 12.5]]) == 1\n assert candidate(bombs = [[5, 5, 10], [15, 5, 10], [5, 15, 10], [15, 15, 10], [10, 10, 5]]) == 5\n assert candidate(bombs = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2], [5, 5, 2], [6, 6, 2], [7, 7, 2], [8, 8, 2], [9, 9, 2]]) == 9\n assert candidate(bombs = [[10, 10, 25], [15, 10, 15], [10, 15, 20], [5, 10, 10], [10, 5, 15]]) == 5\n assert candidate(bombs = [[1, 1, 3], [4, 4, 3], [7, 1, 3], [4, 7, 3], [10, 10, 3]]) == 2\n assert candidate(bombs = [[1, 1, 5], [1, 6, 5], [6, 1, 5], [6, 6, 5], [3, 3, 1]]) == 5\n assert candidate(bombs = [[1, 1, 1000], [2, 2, 1000], [3, 3, 1000], [4, 4, 1000], [5, 5, 1000], [6, 6, 1000], [7, 7, 1000], [8, 8, 1000]]) == 8\n assert candidate(bombs = [[100, 100, 50], [150, 100, 50], [200, 100, 50], [250, 100, 50], [300, 100, 50], [350, 100, 50], [400, 100, 50], [450, 100, 50]]) == 8\n assert candidate(bombs = [[10, 10, 5], [15, 10, 5], [10, 15, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13], [14, 14, 14], [15, 15, 15]]) == 15\n assert candidate(bombs = [[5, 5, 5], [10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5], [35, 35, 5], [40, 40, 5]]) == 1\n assert candidate(bombs = [[50, 50, 50], [60, 60, 50], [70, 70, 50], [80, 80, 50], [90, 90, 50], [100, 100, 50]]) == 6\n assert candidate(bombs = [[50, 50, 50], [100, 100, 50], [150, 150, 50], [200, 200, 50], [250, 250, 50], [300, 300, 50], [350, 350, 50], [400, 400, 50], [450, 450, 50]]) == 1\n assert candidate(bombs = [[10, 10, 5], [15, 15, 3], [20, 20, 4], [25, 25, 2], [30, 30, 6]]) == 1\n assert candidate(bombs = [[10, 10, 15], [15, 15, 15], [20, 20, 15], [25, 25, 15], [30, 30, 15]]) == 5\n assert candidate(bombs = [[10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5]]) == 1\n assert candidate(bombs = [[1, 1, 100], [101, 101, 100], [201, 201, 100], [301, 301, 100], [401, 401, 100]]) == 1\n assert candidate(bombs = [[5, 5, 3], [7, 5, 3], [9, 5, 3], [11, 5, 3], [13, 5, 3]]) == 5\n assert candidate(bombs = [[1, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5], [5, 5, 5], [6, 6, 5], [7, 7, 5], [8, 8, 5], [9, 9, 5]]) == 9\n assert candidate(bombs = [[10000, 10000, 5000], [15000, 10000, 10000], [20000, 10000, 3000], [10000, 20000, 6000], [25000, 25000, 8000]]) == 3\n assert candidate(bombs = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9]]) == 9\n assert candidate(bombs = [[1000, 1000, 1000], [2000, 2000, 500], [3000, 3000, 250], [4000, 4000, 125]]) == 1\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]]) == 5\n assert candidate(bombs = [[10, 10, 50], [20, 20, 40], [30, 30, 30], [40, 40, 20], [50, 50, 10]]) == 5\n assert candidate(bombs = [[5, 5, 10], [10, 10, 10], [15, 15, 10], [20, 20, 10], [25, 25, 10], [30, 30, 10], [35, 35, 10]]) == 7\n assert candidate(bombs = [[10, 10, 10], [20, 20, 10], [30, 30, 10], [40, 40, 10], [50, 50, 10], [60, 60, 10], [70, 70, 10], [80, 80, 10], [90, 90, 10], [100, 100, 10], [110, 110, 10], [120, 120, 10], [130, 130, 10], [140, 140, 10], [150, 150, 10]]) == 1\n assert candidate(bombs = [[1, 1, 10], [10, 1, 5], [10, 10, 15], [20, 20, 10]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7]]) == 7\n assert candidate(bombs = [[1, 1, 10], [10, 1, 5], [1, 10, 5], [5, 5, 2], [7, 7, 7]]) == 5\n assert candidate(bombs = [[1, 1, 10000], [2, 2, 10000], [3, 3, 10000], [4, 4, 10000], [5, 5, 10000], [6, 6, 10000], [7, 7, 10000], [8, 8, 10000], [9, 9, 10000], [10, 10, 10000]]) == 10\n assert candidate(bombs = [[10, 10, 1], [11, 11, 2], [12, 12, 3], [13, 13, 4], [14, 14, 5], [15, 15, 6], [16, 16, 7], [17, 17, 8], [18, 18, 9], [19, 19, 10]]) == 10\n assert candidate(bombs = [[1, 1, 10], [11, 1, 10], [21, 1, 10], [1, 11, 10], [11, 11, 10], [21, 11, 10], [1, 21, 10], [11, 21, 10], [21, 21, 10]]) == 9\n assert candidate(bombs = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 5\n assert candidate(bombs = [[1, 1, 10], [2, 1, 10], [3, 1, 10], [4, 1, 10], [5, 1, 10], [6, 1, 10], [7, 1, 10], [8, 1, 10], [9, 1, 10], [10, 1, 10]]) == 10\n assert candidate(bombs = [[1, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5], [5, 5, 5], [6, 6, 5], [7, 7, 5], [8, 8, 5], [9, 9, 5], [10, 10, 5], [11, 11, 5], [12, 12, 5], [13, 13, 5], [14, 14, 5], [15, 15, 5]]) == 15\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]]) == 9\n assert candidate(bombs = [[5, 5, 5], [10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5], [35, 35, 5], [40, 40, 5], [45, 45, 5], [50, 50, 5]]) == 1\n assert candidate(bombs = [[10, 10, 5], [20, 20, 5], [30, 30, 5], [40, 40, 5], [50, 50, 5], [60, 60, 5], [70, 70, 5], [80, 80, 5], [90, 90, 5], [100, 100, 5], [110, 110, 5], [120, 120, 5], [130, 130, 5], [140, 140, 5], [150, 150, 5]]) == 1\n assert candidate(bombs = [[10, 10, 3], [12, 12, 2], [15, 15, 1], [18, 18, 4], [20, 20, 5]]) == 2\n assert candidate(bombs = [[10, 10, 5], [15, 10, 10], [20, 10, 3], [10, 20, 6], [25, 25, 8]]) == 3\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13]]) == 13\n assert candidate(bombs = [[100, 100, 50], [200, 200, 50], [300, 300, 50], [250, 250, 100]]) == 3\n assert candidate(bombs = [[1, 1, 5], [5, 1, 5], [9, 1, 5], [13, 1, 5]]) == 4\n", "comparison": "exact"}, "public_tests": ["[[2,1,3],[6,1,4]]", "[[1,1,5],[10,10,5]]", "[[1,2,3],[2,3,1],[3,4,2],[4,5,3],[5,6,4]]"], "hints": ["How can we model the relationship between different bombs? Can \"graphs\" help us?", "Bombs are nodes and are connected to other bombs in their range by directed edges.", "If we know which bombs will be affected when any bomb is detonated, how can we find the total number of bombs that will be detonated if we start from a fixed bomb?", "Run a Depth First Search (DFS) from every node, and all the nodes it reaches are the bombs that will be detonated."], "metadata": {"canonical_parameter_names": ["bombs"], "leetcode_dataset_entry_point": "Solution().maximumDetonation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:09+00:00", "tests_total": 115, "tests_dropped": 17, "flags": ["has_images"], "topic_tags": ["array", "math", "depth-first-search", "breadth-first-search", "graph", "geometry"]}, "language": "javascript", "interface": {"raw_signature": "var maximumDetonation = function(bombs) {", "container": null, "callable": "maximumDetonation", "parameters": [{"name": "bombs", "type": "number[][]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2101, "task_id": "detonate-the-maximum-bombs", "difficulty": "Medium", "problem_description": "You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the center as the location of the bomb.\n\nThe bombs are represented by a 0-indexed 2D integer array bombs where bombs[i] = [x_i, y_i, r_i]. x_i and y_i denote the X-coordinate and Y-coordinate of the location of the i^th bomb, whereas r_i denotes the radius of its range.\n\nYou may choose to detonate a single bomb. When a bomb is detonated, it will detonate all bombs that lie in its range. These bombs will further detonate the bombs that lie in their ranges.\n\nGiven the list of bombs, return the maximum number of bombs that can be detonated if you are allowed to detonate only one bomb.\n\nExample 1:\n\nInput: bombs = [[2,1,3],[6,1,4]]\nOutput: 2\nExplanation:\nThe above figure shows the positions and ranges of the 2 bombs.\nIf we detonate the left bomb, the right bomb will not be affected.\nBut if we detonate the right bomb, both bombs will be detonated.\nSo the maximum bombs that can be detonated is max(1, 2) = 2.\n\nExample 2:\n\nInput: bombs = [[1,1,5],[10,10,5]]\nOutput: 1\nExplanation:\nDetonating either bomb will not detonate the other bomb, so the maximum number of bombs that can be detonated is 1.\n\nExample 3:\n\nInput: bombs = [[1,2,3],[2,3,1],[3,4,2],[4,5,3],[5,6,4]]\nOutput: 5\nExplanation:\nThe best bomb to detonate is bomb 0 because:\n- Bomb 0 detonates bombs 1 and 2. The red circle denotes the range of bomb 0.\n- Bomb 2 detonates bomb 3. The blue circle denotes the range of bomb 2.\n- Bomb 3 detonates bomb 4. The green circle denotes the range of bomb 3.\nThus all 5 bombs are detonated.\n\nConstraints:\n\n- 1 <= bombs.length <= 100\n- bombs[i].length == 3\n- 1 <= x_i, y_i, r_i <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(bombs = [[10, 10, 5], [15, 15, 5], [20, 20, 5]]) == 1\n assert candidate(bombs = [[1, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 1], [3, 3, 1]]) == 1\n assert candidate(bombs = [[1, 1, 100], [1, 1, 50], [1, 1, 25]]) == 3\n assert candidate(bombs = [[1, 1, 10], [10, 10, 10], [5, 5, 5]]) == 2\n assert candidate(bombs = [[1, 1, 10], [10, 10, 1], [5, 5, 5]]) == 2\n assert candidate(bombs = [[1, 1, 5], [10, 10, 5]]) == 1\n assert candidate(bombs = [[1, 2, 3], [2, 3, 1], [3, 4, 2], [4, 5, 3], [5, 6, 4]]) == 5\n assert candidate(bombs = [[5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1]]) == 1\n assert candidate(bombs = [[100, 100, 1], [101, 101, 1], [102, 102, 1]]) == 1\n assert candidate(bombs = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2]]) == 4\n assert candidate(bombs = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 3\n assert candidate(bombs = [[2, 1, 3], [6, 1, 4]]) == 2\n assert candidate(bombs = [[1, 1, 3], [2, 2, 3], [3, 3, 3], [4, 4, 3]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1]]) == 1\n assert candidate(bombs = [[5, 5, 3], [6, 6, 1], [7, 7, 4]]) == 3\n assert candidate(bombs = [[5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8]]) == 4\n assert candidate(bombs = [[10, 10, 10], [20, 20, 10], [30, 30, 10]]) == 1\n assert candidate(bombs = [[10, 10, 1], [20, 10, 1], [30, 10, 1], [40, 10, 1], [50, 10, 1], [60, 10, 1], [70, 10, 1], [80, 10, 1], [90, 10, 1], [100, 10, 1]]) == 1\n assert candidate(bombs = [[100, 100, 10], [100, 110, 10], [100, 120, 10], [110, 100, 10], [110, 110, 10], [110, 120, 10], [120, 100, 10], [120, 110, 10], [120, 120, 10]]) == 9\n assert candidate(bombs = [[10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5], [35, 35, 5], [40, 40, 5]]) == 1\n assert candidate(bombs = [[50, 50, 10], [60, 60, 20], [70, 70, 30], [80, 80, 40], [90, 90, 50]]) == 5\n assert candidate(bombs = [[10, 10, 3], [10, 13, 3], [13, 10, 3], [13, 13, 3], [16, 16, 3], [16, 19, 3], [19, 16, 3], [19, 19, 3]]) == 4\n assert candidate(bombs = [[1, 1, 10], [1, 10, 10], [10, 1, 10], [10, 10, 10], [15, 15, 15], [15, 5, 15], [5, 15, 15], [20, 20, 5]]) == 8\n assert candidate(bombs = [[50, 50, 5], [55, 50, 5], [60, 50, 5], [65, 50, 5], [70, 50, 5], [75, 50, 5], [80, 50, 5], [85, 50, 5], [90, 50, 5], [95, 50, 5], [100, 50, 5], [105, 50, 5], [110, 50, 5], [115, 50, 5], [120, 50, 5], [125, 50, 5], [130, 50, 5], [135, 50, 5], [140, 50, 5], [145, 50, 5]]) == 20\n assert candidate(bombs = [[100, 100, 10], [110, 100, 10], [120, 100, 10], [130, 100, 10], [140, 100, 10], [150, 100, 10], [160, 100, 10], [170, 100, 10], [180, 100, 10]]) == 9\n assert candidate(bombs = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1]]) == 1\n assert candidate(bombs = [[50, 50, 5], [60, 50, 5], [70, 50, 5], [80, 50, 5], [50, 60, 5], [50, 70, 5], [50, 80, 5], [50, 90, 5], [50, 100, 5], [60, 60, 15]]) == 6\n assert candidate(bombs = [[100, 100, 50], [200, 100, 50], [100, 200, 50], [200, 200, 50], [150, 150, 100]]) == 5\n assert candidate(bombs = [[10, 10, 1], [20, 20, 1], [30, 30, 1], [40, 40, 1], [50, 50, 1], [60, 60, 1], [70, 70, 1], [80, 80, 1], [90, 90, 1], [100, 100, 100]]) == 8\n assert candidate(bombs = [[5, 5, 5], [5, 15, 5], [15, 5, 5], [15, 15, 5], [10, 10, 20]]) == 5\n assert candidate(bombs = [[1, 1, 5], [2, 2, 10], [3, 3, 2], [4, 4, 8], [5, 5, 1]]) == 5\n assert candidate(bombs = [[1, 1, 100], [1, 1, 100], [1, 1, 100], [1, 1, 100], [1, 1, 100]]) == 5\n assert candidate(bombs = [[50, 50, 15], [60, 50, 20], [70, 50, 10], [50, 60, 25], [50, 70, 12], [50, 80, 5]]) == 6\n assert candidate(bombs = [[1, 1, 10], [10, 1, 10], [1, 10, 10], [10, 10, 10], [5, 5, 5], [15, 15, 15]]) == 6\n assert candidate(bombs = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9], [1, 10, 10]]) == 10\n assert candidate(bombs = [[1, 1, 10], [20, 20, 10], [30, 30, 10], [40, 40, 10], [50, 50, 10], [60, 60, 10]]) == 1\n assert candidate(bombs = [[100, 100, 50], [200, 200, 50], [300, 300, 50], [100, 200, 60], [200, 300, 70]]) == 1\n assert candidate(bombs = [[10, 10, 1], [15, 15, 2], [20, 20, 3], [25, 25, 4], [30, 30, 5]]) == 1\n assert candidate(bombs = [[5, 5, 1], [5, 6, 1], [5, 7, 1], [5, 8, 1], [5, 9, 1]]) == 5\n assert candidate(bombs = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40], [5, 5, 50], [6, 6, 60]]) == 6\n assert candidate(bombs = [[5, 5, 20], [10, 5, 20], [15, 5, 20], [20, 5, 20], [25, 5, 20], [30, 5, 20], [35, 5, 20], [40, 5, 20], [45, 5, 20], [50, 5, 20]]) == 10\n assert candidate(bombs = [[1, 1, 100], [200, 200, 100], [400, 400, 100], [600, 600, 100], [800, 800, 100], [1000, 1000, 100], [1200, 1200, 100], [1400, 1400, 100], [1600, 1600, 100], [1800, 1800, 100]]) == 1\n assert candidate(bombs = [[10, 10, 15], [20, 20, 15], [30, 30, 15], [40, 40, 15], [50, 50, 15], [60, 60, 15], [70, 70, 15], [80, 80, 15], [90, 90, 15]]) == 9\n assert candidate(bombs = [[10, 10, 15], [20, 20, 15], [30, 30, 15], [40, 40, 15], [50, 50, 15], [60, 60, 15], [70, 70, 15]]) == 7\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]]) == 10\n assert candidate(bombs = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10]]) == 8\n assert candidate(bombs = [[100, 100, 100], [200, 100, 100], [300, 100, 100], [400, 100, 100], [500, 100, 100], [600, 100, 100], [700, 100, 100], [800, 100, 100], [900, 100, 100]]) == 9\n assert candidate(bombs = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1]]) == 1\n assert candidate(bombs = [[10, 10, 5], [15, 10, 5], [20, 10, 5], [25, 10, 5], [30, 10, 5], [35, 10, 5], [40, 10, 5], [45, 10, 5]]) == 8\n assert candidate(bombs = [[1, 1, 100], [1, 101, 100], [101, 101, 100], [101, 1, 100], [51, 51, 100], [51, 1, 100], [1, 51, 100], [101, 51, 100], [51, 101, 100]]) == 9\n assert candidate(bombs = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2], [5, 5, 2], [6, 6, 2]]) == 6\n assert candidate(bombs = [[10, 10, 20], [30, 30, 20], [50, 50, 20], [70, 70, 20], [90, 90, 20], [110, 110, 20], [130, 130, 20], [150, 150, 20], [170, 170, 20], [190, 190, 20], [210, 210, 20], [230, 230, 20], [250, 250, 20], [270, 270, 20], [290, 290, 20]]) == 1\n assert candidate(bombs = [[5, 5, 2], [10, 5, 2], [15, 5, 2], [20, 5, 2], [25, 5, 2], [30, 5, 2], [35, 5, 2], [40, 5, 2], [45, 5, 2], [50, 5, 2], [55, 5, 2]]) == 1\n assert candidate(bombs = [[10, 10, 15], [20, 20, 25], [30, 30, 35], [40, 40, 45], [50, 50, 55]]) == 5\n assert candidate(bombs = [[5, 5, 10], [15, 5, 10], [5, 15, 10], [15, 15, 10], [10, 10, 5]]) == 5\n assert candidate(bombs = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2], [5, 5, 2], [6, 6, 2], [7, 7, 2], [8, 8, 2], [9, 9, 2]]) == 9\n assert candidate(bombs = [[10, 10, 25], [15, 10, 15], [10, 15, 20], [5, 10, 10], [10, 5, 15]]) == 5\n assert candidate(bombs = [[1, 1, 3], [4, 4, 3], [7, 1, 3], [4, 7, 3], [10, 10, 3]]) == 2\n assert candidate(bombs = [[1, 1, 5], [1, 6, 5], [6, 1, 5], [6, 6, 5], [3, 3, 1]]) == 5\n assert candidate(bombs = [[1, 1, 1000], [2, 2, 1000], [3, 3, 1000], [4, 4, 1000], [5, 5, 1000], [6, 6, 1000], [7, 7, 1000], [8, 8, 1000]]) == 8\n assert candidate(bombs = [[100, 100, 50], [150, 100, 50], [200, 100, 50], [250, 100, 50], [300, 100, 50], [350, 100, 50], [400, 100, 50], [450, 100, 50]]) == 8\n assert candidate(bombs = [[10, 10, 5], [15, 10, 5], [10, 15, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13], [14, 14, 14], [15, 15, 15]]) == 15\n assert candidate(bombs = [[5, 5, 5], [10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5], [35, 35, 5], [40, 40, 5]]) == 1\n assert candidate(bombs = [[50, 50, 50], [60, 60, 50], [70, 70, 50], [80, 80, 50], [90, 90, 50], [100, 100, 50]]) == 6\n assert candidate(bombs = [[50, 50, 50], [100, 100, 50], [150, 150, 50], [200, 200, 50], [250, 250, 50], [300, 300, 50], [350, 350, 50], [400, 400, 50], [450, 450, 50]]) == 1\n assert candidate(bombs = [[10, 10, 5], [15, 15, 3], [20, 20, 4], [25, 25, 2], [30, 30, 6]]) == 1\n assert candidate(bombs = [[10, 10, 15], [15, 15, 15], [20, 20, 15], [25, 25, 15], [30, 30, 15]]) == 5\n assert candidate(bombs = [[10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5]]) == 1\n assert candidate(bombs = [[1, 1, 100], [101, 101, 100], [201, 201, 100], [301, 301, 100], [401, 401, 100]]) == 1\n assert candidate(bombs = [[5, 5, 3], [7, 5, 3], [9, 5, 3], [11, 5, 3], [13, 5, 3]]) == 5\n assert candidate(bombs = [[1, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5], [5, 5, 5], [6, 6, 5], [7, 7, 5], [8, 8, 5], [9, 9, 5]]) == 9\n assert candidate(bombs = [[10000, 10000, 5000], [15000, 10000, 10000], [20000, 10000, 3000], [10000, 20000, 6000], [25000, 25000, 8000]]) == 3\n assert candidate(bombs = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9]]) == 9\n assert candidate(bombs = [[1000, 1000, 1000], [2000, 2000, 500], [3000, 3000, 250], [4000, 4000, 125]]) == 1\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]]) == 5\n assert candidate(bombs = [[10, 10, 50], [20, 20, 40], [30, 30, 30], [40, 40, 20], [50, 50, 10]]) == 5\n assert candidate(bombs = [[5, 5, 10], [10, 10, 10], [15, 15, 10], [20, 20, 10], [25, 25, 10], [30, 30, 10], [35, 35, 10]]) == 7\n assert candidate(bombs = [[10, 10, 10], [20, 20, 10], [30, 30, 10], [40, 40, 10], [50, 50, 10], [60, 60, 10], [70, 70, 10], [80, 80, 10], [90, 90, 10], [100, 100, 10], [110, 110, 10], [120, 120, 10], [130, 130, 10], [140, 140, 10], [150, 150, 10]]) == 1\n assert candidate(bombs = [[1, 1, 10], [10, 1, 5], [10, 10, 15], [20, 20, 10]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7]]) == 7\n assert candidate(bombs = [[1, 1, 10], [10, 1, 5], [1, 10, 5], [5, 5, 2], [7, 7, 7]]) == 5\n assert candidate(bombs = [[1, 1, 10000], [2, 2, 10000], [3, 3, 10000], [4, 4, 10000], [5, 5, 10000], [6, 6, 10000], [7, 7, 10000], [8, 8, 10000], [9, 9, 10000], [10, 10, 10000]]) == 10\n assert candidate(bombs = [[10, 10, 1], [11, 11, 2], [12, 12, 3], [13, 13, 4], [14, 14, 5], [15, 15, 6], [16, 16, 7], [17, 17, 8], [18, 18, 9], [19, 19, 10]]) == 10\n assert candidate(bombs = [[1, 1, 10], [11, 1, 10], [21, 1, 10], [1, 11, 10], [11, 11, 10], [21, 11, 10], [1, 21, 10], [11, 21, 10], [21, 21, 10]]) == 9\n assert candidate(bombs = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 5\n assert candidate(bombs = [[1, 1, 10], [2, 1, 10], [3, 1, 10], [4, 1, 10], [5, 1, 10], [6, 1, 10], [7, 1, 10], [8, 1, 10], [9, 1, 10], [10, 1, 10]]) == 10\n assert candidate(bombs = [[1, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5], [5, 5, 5], [6, 6, 5], [7, 7, 5], [8, 8, 5], [9, 9, 5], [10, 10, 5], [11, 11, 5], [12, 12, 5], [13, 13, 5], [14, 14, 5], [15, 15, 5]]) == 15\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]]) == 9\n assert candidate(bombs = [[5, 5, 5], [10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5], [35, 35, 5], [40, 40, 5], [45, 45, 5], [50, 50, 5]]) == 1\n assert candidate(bombs = [[10, 10, 5], [20, 20, 5], [30, 30, 5], [40, 40, 5], [50, 50, 5], [60, 60, 5], [70, 70, 5], [80, 80, 5], [90, 90, 5], [100, 100, 5], [110, 110, 5], [120, 120, 5], [130, 130, 5], [140, 140, 5], [150, 150, 5]]) == 1\n assert candidate(bombs = [[10, 10, 3], [12, 12, 2], [15, 15, 1], [18, 18, 4], [20, 20, 5]]) == 2\n assert candidate(bombs = [[10, 10, 5], [15, 10, 10], [20, 10, 3], [10, 20, 6], [25, 25, 8]]) == 3\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13]]) == 13\n assert candidate(bombs = [[100, 100, 50], [200, 200, 50], [300, 300, 50], [250, 250, 100]]) == 3\n assert candidate(bombs = [[1, 1, 5], [5, 1, 5], [9, 1, 5], [13, 1, 5]]) == 4\n", "comparison": "exact"}, "public_tests": ["[[2,1,3],[6,1,4]]", "[[1,1,5],[10,10,5]]", "[[1,2,3],[2,3,1],[3,4,2],[4,5,3],[5,6,4]]"], "hints": ["How can we model the relationship between different bombs? Can \"graphs\" help us?", "Bombs are nodes and are connected to other bombs in their range by directed edges.", "If we know which bombs will be affected when any bomb is detonated, how can we find the total number of bombs that will be detonated if we start from a fixed bomb?", "Run a Depth First Search (DFS) from every node, and all the nodes it reaches are the bombs that will be detonated."], "metadata": {"canonical_parameter_names": ["bombs"], "leetcode_dataset_entry_point": "Solution().maximumDetonation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:09+00:00", "tests_total": 115, "tests_dropped": 18, "flags": ["has_images"], "topic_tags": ["array", "math", "depth-first-search", "breadth-first-search", "graph", "geometry"]}, "language": "javascript", "interface": {"raw_signature": "var maximumDetonation = function(bombs) {", "container": null, "callable": "maximumDetonation", "parameters": [{"name": "bombs", "type": "number[][]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2103, "task_id": "rings-and-rods", "difficulty": "Easy", "problem_description": "There are n rings and each ring is either red, green, or blue. The rings are distributed across ten rods labeled from 0 to 9.\n\nYou are given a string rings of length 2n that describes the n rings that are placed onto the rods. Every two characters in rings forms a color-position pair that is used to describe each ring where:\n\n- The first character of the i^th pair denotes the i^th ring's color ('R', 'G', 'B').\n- The second character of the i^th pair denotes the rod that the i^th ring is placed on ('0' to '9').\n\nFor example, \"R3G2B1\" describes n == 3 rings: a red ring placed onto the rod labeled 3, a green ring placed onto the rod labeled 2, and a blue ring placed onto the rod labeled 1.\n\nReturn the number of rods that have all three colors of rings on them.\n\nExample 1:\n\nInput: rings = \"B0B6G0R6R0R6G9\"\nOutput: 1\nExplanation:\n- The rod labeled 0 holds 3 rings with all colors: red, green, and blue.\n- The rod labeled 6 holds 3 rings, but it only has red and blue.\n- The rod labeled 9 holds only a green ring.\nThus, the number of rods with all three colors is 1.\n\nExample 2:\n\nInput: rings = \"B0R0G0R9R0B0G0\"\nOutput: 1\nExplanation:\n- The rod labeled 0 holds 6 rings with all colors: red, green, and blue.\n- The rod labeled 9 holds only a red ring.\nThus, the number of rods with all three colors is 1.\n\nExample 3:\n\nInput: rings = \"G4\"\nOutput: 0\nExplanation:\nOnly one ring is given. Thus, no rods have all three colors.\n\nConstraints:\n\n- rings.length == 2 * n\n- 1 <= n <= 100\n- rings[i] where i is even is either 'R', 'G', or 'B' (0-indexed).\n- rings[i] where i is odd is a digit from '0' to '9' (0-indexed).\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2\") == 3\n assert candidate(rings = \"R9G9B9R9G9B9R9G9B9\") == 1\n assert candidate(rings = \"G4\") == 0\n assert candidate(rings = \"R0G0R0G0R0G0\") == 0\n assert candidate(rings = \"G0G1G2G3G4G5G6G7G8G9\") == 0\n assert candidate(rings = \"B0B1B2B3B4B5B6B7B8B9\") == 0\n assert candidate(rings = \"G1G2G3G4G5G6G7G8G9G0\") == 0\n assert candidate(rings = \"R1R2R3R4R5R6R7R8R9R0\") == 0\n assert candidate(rings = \"B0B6G0R6R0R6G9\") == 1\n assert candidate(rings = \"R9G9B9\") == 1\n assert candidate(rings = \"B1B2B3B4B5B6B7B8B9B0\") == 0\n assert candidate(rings = \"R0R0G0G0B0B0R1R1G1G1B1B1\") == 2\n assert candidate(rings = \"B0R0G0R9R0B0G0\") == 1\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9\") == 0\n assert candidate(rings = \"R1R1R1G1G1G1B1B1B1\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0R1R2R3R4R5R6R7R8R9\") == 0\n assert candidate(rings = \"R9G9B9R9G9B9\") == 1\n assert candidate(rings = \"R0G0B0R1G0B0R2G0B0R3G0B0R4G0B0R5G0B0R6G0B0R7G0B0R8G0B0R9G0B0\") == 1\n assert candidate(rings = \"R5G5B5R5G5B5R5G5B5\") == 1\n assert candidate(rings = \"R1G1B1R2G2B2R3G3B3\") == 3\n assert candidate(rings = \"B9B9B9G9G9G9R9R9R9\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R1G1B1R2G2B2\") == 2\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R2G2B2R4G4B4R6G6B6R8G8B8\") == 5\n assert candidate(rings = \"R9G9B9R8G8B8R7G7B7\") == 3\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R1G1B1R2G2B2R2G2B2R2G2B2R2G2B2\") == 3\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0R1G2B3R4G5B6R7G8B9\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0R1G2B3R4G5B6R7G8B9R0G1B2R3G4B5\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R0G0B0R1G1B1R2G2B2R3G3B3R0G0B0\") == 4\n assert candidate(rings = \"R0R0G0G0B0B0R1R1G1G1B1B1R2R2G2G2B2B2R3R3G3G3B3B3R4R4G4G4B4B4R5R5G5G5B5B5\") == 6\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G0B1R2G0B2R3G0B3R4G0B4R5G0B5R6G0B6R7G0B7R8G0B8R9G0B9R0G0B0R1G0B1R2G0B2R3G0B3R4G0B4R5G0B5R6G0B6R7G0B7R8G0B8R9G0B9\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R1G1B1\") == 10\n assert candidate(rings = \"R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1\") == 10\n assert candidate(rings = \"R0R0R0R0R0R0R0R0R0R0G0G0G0G0G0G0G0G0G0G0G0G0B0B0B0B0B0B0B0B0B0B0\") == 1\n assert candidate(rings = \"R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2\") == 0\n assert candidate(rings = \"R0G0B0R0G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 9\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0\") == 10\n assert candidate(rings = \"R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3\") == 0\n assert candidate(rings = \"R0G0B0R1G0B0R2G0B0R3G0B0R4G0B0R5G0B0R6G0B0R7G0B0R8G0B0R9G0B0R0G0B0R1G0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R9G9B9R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R0G0B0R0G0B0\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0R1G1B1R2G2B2R3G3B3\") == 4\n assert candidate(rings = \"R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3\") == 0\n assert candidate(rings = \"R9G9B9R8G8B8R7G7B7R6G6B6R5G5B5R4G4B4R3G3B3R2G2B2R1G1B1R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R2G2B2R2G2B2R2G2B2R3G3B3\") == 4\n assert candidate(rings = \"R0R0R0R0R0R1R1R1R1R1R2R2R2R2R2R3R3R3R3R3R4R4R4R4R4R5R5R5R5R5R6R6R6R6R6R7R7R7R7R7R8R8R8R8R8R9R9R9R9R9\") == 0\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0G0B0R1G1B1R1G1B2G2B2R2G2B3G3B3R3G3B4G4B4R4G4B5G5B5R5G5B6G6B6R6G6B7G7B7R7G7B8G8B8R8G8B9G9B9R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R8G8B8\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1\") == 2\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1\") == 2\n assert candidate(rings = \"R9G8B7R6G5B4R3G2B1R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5\") == 6\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R7G7B7R7G7B7R7G7B7\") == 10\n assert candidate(rings = \"R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2\") == 0\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 10\n assert candidate(rings = \"R9G9B9R8G8B8R7G7B7R6G6B6R5G5B5R4G4B4R3G3B3R2G2B2R1G1B1R0G0B0\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0R1G2B3R4G5B6R7G8B9R0G1B2R3G4B5R6G7B8R9G0\") == 10\n assert candidate(rings = \"R0B0G1R1B1G2R2B2G3R3B3G4R4B4G5R5B5G6R6B6G7R7B7G8R8B8G9R9B9\") == 9\n assert candidate(rings = \"R0G0B0G0B0R0B0G0R0R0G0B0R0G0B0R0R0G0R0G0B0R0B0G0R0G0R0B0G0R0\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0\") == 0\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R6G6B6R6G6B6R6G6B6R6G6B6\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R4G4B4R4G4B4R4G4B4R4G4B4R4G4B4R4G4B4R4G4B4R4G4B4\") == 10\n assert candidate(rings = \"R0R0R0G0G0G0B0B0B0R1R1R1G1G1G1B1B1B1R2R2R2G2G2G2B2B2B2\") == 3\n assert candidate(rings = \"R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0R0R0R0R0R0R0R0R0R0G0G0G0G0G0G0G0G0G0G0G0B0B0B0B0B0B0B0B0B0B0B0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4\") == 10\n assert candidate(rings = \"R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2\") == 0\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R1G1B1\") == 2\n assert candidate(rings = \"G0B0R0G1B1R1G2B2R2G3B3R3G4B4R4G5B5R5G6B6R6G7B7R7G8B8R8G9B9R9G0B0R0G1B1R1G2B2R2G3B3R3G4B4R4G5B5R5G6B6R6G7B7R7G8B8R8G9B9R9\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0\") == 1\n assert candidate(rings = \"B9G9R9B8G8R8B7G7R7B6G6R6B5G5R5B4G4R4B3G3R3B2G2R2B1G1R1B0G0R0B9G9R9B8G8R8B7G7R7B6G6R6B5G5R5B4G4R4B3G3R3B2G2R2B1G1R1B0G0R0\") == 10\n assert candidate(rings = \"R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0\") == 10\n assert candidate(rings = \"B0G0B0G0B0R1G1R1G1R1B2G2B2G2G2R3G3R3G3G3B4G4B4G4G4R5G5R5G5G5B6G6B6G6G6R7G7R7G7G7B8G8B8G8G8R9G9R9G9G9B9G9B9G9G9\") == 1\n assert candidate(rings = \"G0B0R0G1B1R1G2B2R2G3B3R3G4B4R4G5B5R5G6B6R6G7B7R7G8B8R8G9B9R9G0B1R2G3B4R5G6B7R8G9B0\") == 10\n assert candidate(rings = \"R0G0B0R0G1B1R0G2B2R0G3B3R0G4B4R0G5B5R0G6B6R0G7B7R0G8B8R0G9B9\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0\") == 10\n assert candidate(rings = \"R0B1G2R3B4G5R6B7G8R9B0G1R2B3G4R5B6G7R8B9G0R1B2G3R4B5G6R7B8G9\") == 10\n assert candidate(rings = \"B9G8R7B6G5R4B3G2R1B0G9R8B7G6R5B4G3R2B1G0R9B8G7R6B5G4R3B2G1R0\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n", "comparison": "exact"}, "public_tests": ["\"B0B6G0R6R0R6G9\"", "\"B0R0G0R9R0B0G0\"", "\"G4\""], "hints": ["For every rod, look through ‘rings’ to see if the rod contains all colors.", "Create 3 booleans, 1 for each color, to store if that color is present for the current rod. If all 3 are true after looking through the string, then the rod contains all the colors."], "metadata": {"canonical_parameter_names": ["rings"], "leetcode_dataset_entry_point": "Solution().countPoints", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:12+00:00", "tests_total": 99, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["hash-table", "string"]}, "language": "javascript", "interface": {"raw_signature": "var countPoints = function(rings) {", "container": null, "callable": "countPoints", "parameters": [{"name": "rings", "type": "string"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2104, "task_id": "sum-of-subarray-ranges", "difficulty": "Medium", "problem_description": "You are given an integer array nums. The range of a subarray of nums is the difference between the largest and smallest element in the subarray.\n\nReturn the sum of all subarray ranges of nums.\n\nA subarray is a contiguous non-empty sequence of elements within an array.\n\nExample 1:\n\nInput: nums = [1,2,3]\nOutput: 4\nExplanation: The 6 subarrays of nums are the following:\n[1], range = largest - smallest = 1 - 1 = 0\n[2], range = 2 - 2 = 0\n[3], range = 3 - 3 = 0\n[1,2], range = 2 - 1 = 1\n[2,3], range = 3 - 2 = 1\n[1,2,3], range = 3 - 1 = 2\nSo the sum of all ranges is 0 + 0 + 0 + 1 + 1 + 2 = 4.\n\nExample 2:\n\nInput: nums = [1,3,3]\nOutput: 4\nExplanation: The 6 subarrays of nums are the following:\n[1], range = largest - smallest = 1 - 1 = 0\n[3], range = 3 - 3 = 0\n[3], range = 3 - 3 = 0\n[1,3], range = 3 - 1 = 2\n[3,3], range = 3 - 3 = 0\n[1,3,3], range = 3 - 1 = 2\nSo the sum of all ranges is 0 + 0 + 0 + 2 + 0 + 2 = 4.\n\nExample 3:\n\nInput: nums = [4,-2,-3,4,1]\nOutput: 59\nExplanation: The sum of all subarray ranges of nums is 59.\n\nConstraints:\n\n- 1 <= nums.length <= 1000\n- -10^9 <= nums[i] <= 10^9\n\nFollow-up: Could you find a solution with O(n) time complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, -2, -3, -4]) == 10\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 165\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 165\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == 30\n assert candidate(nums = [4, -2, -3, 4, 1]) == 59\n assert candidate(nums = [3, 2, 2, 2, 1]) == 8\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 20000000000\n assert candidate(nums = [10, 20, 30, 40, 50]) == 200\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 20\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 20\n assert candidate(nums = [100, 100, 100, 100]) == 0\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000]) == 12000000000\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == 700\n assert candidate(nums = [10, 20, 30, 40, 50]) == 200\n assert candidate(nums = [1, 2, 2, 2, 3]) == 8\n assert candidate(nums = [5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [-10, -20, -30, -40, -50]) == 200\n assert candidate(nums = [1, 3, 3]) == 4\n assert candidate(nums = [1, 2, 3]) == 4\n assert candidate(nums = [-10, 100, -20, 200, -30, 300]) == 3580\n assert candidate(nums = [5]) == 0\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1]) == 66\n assert candidate(nums = [-1, 4, -2, 3, -3]) == 60\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 45\n assert candidate(nums = [1, 0, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 384\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 16500\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 64\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50]) == 2400\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 190\n assert candidate(nums = [10, 20, 30, 25, 15, 10, 5, 2, 1, 0]) == 743\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 105\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 560\n assert candidate(nums = [5, 3, 8, 1, 4]) == 57\n assert candidate(nums = [10, 20, 30, 25, 15, 5]) == 240\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4]) == 168\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000]) == 12000000000\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 330\n assert candidate(nums = [5, 1, 4, 2, 8, 3]) == 77\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == 60\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 1540\n assert candidate(nums = [100, 200, 300, 400, 500, -500, -400, -300, -200, -100]) == 29000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 560\n assert candidate(nums = [100, 200, 300, 400, 500]) == 2000\n assert candidate(nums = [10, 20, 30, 40, 50, -50, -40, -30, -20, -10]) == 2900\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 20000000000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 635\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == 36000\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1540\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 40\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100, 10, 1, 0, 1, 10, 100]) == 1149\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1]) == 66\n assert candidate(nums = [9, -8, 7, -6, 5, -4, 3, -2, 1]) == 444\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 330\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 80\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1]) == 28\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 480\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 1655\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 240\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40]) == 1680\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10]) == 210\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 45\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 250000000, -250000000]) == 21000000000\n assert candidate(nums = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 5600\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1650\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 330\n assert candidate(nums = [5, 8, 6, 7, 9, 1, 2, 3, 4, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1736\n assert candidate(nums = [9, 7, 5, 3, 1]) == 40\n assert candidate(nums = [5, 8, 3, 7, 9, 1]) == 87\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0]) == 22000\n assert candidate(nums = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10]) == 180\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 20\n assert candidate(nums = [10, -5, 3, 7, -2, 8]) == 172\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1]) == 42\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 165\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 330\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [-1, -5, -9, -3, -6]) == 59\n assert candidate(nums = [100, 200, 300, 400, 500, 600]) == 3500\n assert candidate(nums = [1, 5, 3, 7, 9, 2, 6, 8, 4, 10]) == 283\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 560\n assert candidate(nums = [5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 165\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5]) == 240\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 1650\n assert candidate(nums = [5, 2, 9, 1, 5, 6]) == 99\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 328\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 651\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1540\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 285\n assert candidate(nums = [100, -100, 200, -200, 300]) == 4000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 8550\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 235\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 6150\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1000000000, 1000000000, -1000000000, -1000000000]) == 8000000000\n assert candidate(nums = [-1, 2, -3, 4, -5]) == 70\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 250000000]) == 15250000000\n assert candidate(nums = [100, -200, 300, -400, 500]) == 7000\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 220\n assert candidate(nums = [5, 3, 1, 2, 4]) == 27\n assert candidate(nums = [5, 2, 3, 1, 4, 6, 8, 7, 9, 0]) == 244\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 2660\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 45\n assert candidate(nums = [5, 3, 8, 1, 4]) == 57\n assert candidate(nums = [5, 2, 4, 6, 1, 3]) == 60\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1]) == 56\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 330\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1650\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 90\n assert candidate(nums = [5, 3, 8, 2, 7]) == 53\n assert candidate(nums = [5, 1, 4, 3, 2]) == 29\n assert candidate(nums = [1, 2, 3, -1, -2, -3, 4, 5, 6]) == 201\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == 2135\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 1650\n assert candidate(nums = [1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 3]) == 392\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 165000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 5600\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7]) == 560\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1540\n", "comparison": "exact"}, "public_tests": ["[1,2,3]", "[1,3,3]", "[4,-2,-3,4,1]"], "hints": ["Can you get the max/min of a certain subarray by using the max/min of a smaller subarray within it?", "Notice that the max of the subarray from index i to j is equal to max of (max of the subarray from index i to j-1) and nums[j]."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().subArrayRanges", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:14+00:00", "tests_total": 127, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "stack", "monotonic-stack"]}, "language": "javascript", "interface": {"raw_signature": "var subArrayRanges = function(nums) {", "container": null, "callable": "subArrayRanges", "parameters": [{"name": "nums", "type": "number[]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2105, "task_id": "watering-plants-ii", "difficulty": "Medium", "problem_description": "Alice and Bob want to water n plants in their garden. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the i^th plant is located at x = i.\n\nEach plant needs a specific amount of water. Alice and Bob have a watering can each, initially full. They water the plants in the following way:\n\n- Alice waters the plants in order from left to right, starting from the 0^th plant. Bob waters the plants in order from right to left, starting from the (n - 1)^th plant. They begin watering the plants simultaneously.\n- It takes the same amount of time to water each plant regardless of how much water it needs.\n- Alice/Bob must water the plant if they have enough in their can to fully water it. Otherwise, they first refill their can (instantaneously) then water the plant.\n- In case both Alice and Bob reach the same plant, the one with more water currently in his/her watering can should water this plant. If they have the same amount of water, then Alice should water this plant.\n\nGiven a 0-indexed integer array plants of n integers, where plants[i] is the amount of water the i^th plant needs, and two integers capacityA and capacityB representing the capacities of Alice's and Bob's watering cans respectively, return the number of times they have to refill to water all the plants.\n\nExample 1:\n\nInput: plants = [2,2,3,3], capacityA = 5, capacityB = 5\nOutput: 1\nExplanation:\n- Initially, Alice and Bob have 5 units of water each in their watering cans.\n- Alice waters plant 0, Bob waters plant 3.\n- Alice and Bob now have 3 units and 2 units of water respectively.\n- Alice has enough water for plant 1, so she waters it. Bob does not have enough water for plant 2, so he refills his can then waters it.\nSo, the total number of times they have to refill to water all the plants is 0 + 0 + 1 + 0 = 1.\n\nExample 2:\n\nInput: plants = [2,2,3,3], capacityA = 3, capacityB = 4\nOutput: 2\nExplanation:\n- Initially, Alice and Bob have 3 units and 4 units of water in their watering cans respectively.\n- Alice waters plant 0, Bob waters plant 3.\n- Alice and Bob now have 1 unit of water each, and need to water plants 1 and 2 respectively.\n- Since neither of them have enough water for their current plants, they refill their cans and then water the plants.\nSo, the total number of times they have to refill to water all the plants is 0 + 1 + 1 + 0 = 2.\n\nExample 3:\n\nInput: plants = [5], capacityA = 10, capacityB = 8\nOutput: 0\nExplanation:\n- There is only one plant.\n- Alice's watering can has 10 units of water, whereas Bob's can has 8 units. Since Alice has more water in her can, she waters this plant.\nSo, the total number of times they have to refill is 0.\n\nConstraints:\n\n- n == plants.length\n- 1 <= n <= 10^5\n- 1 <= plants[i] <= 10^6\n- max(plants[i]) <= capacityA, capacityB <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(plants = [5],capacityA = 10,capacityB = 8) == 0\n assert candidate(plants = [1000000, 1000000, 1000000],capacityA = 1000000,capacityB = 1000000) == 1\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 15,capacityB = 15) == 3\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 10,capacityB = 10) == 5\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 15,capacityB = 15) == 3\n assert candidate(plants = [2, 2, 3, 3],capacityA = 5,capacityB = 5) == 1\n assert candidate(plants = [1000000],capacityA = 1000000,capacityB = 1000000) == 0\n assert candidate(plants = [2, 2, 3, 3],capacityA = 3,capacityB = 4) == 2\n assert candidate(plants = [1, 10, 1, 10, 1, 10, 1, 10],capacityA = 10,capacityB = 10) == 6\n assert candidate(plants = [5, 8, 6],capacityA = 10,capacityB = 10) == 1\n assert candidate(plants = [10, 10, 10, 10, 10],capacityA = 10,capacityB = 10) == 3\n assert candidate(plants = [1, 2, 3, 4, 5],capacityA = 5,capacityB = 5) == 2\n assert candidate(plants = [10, 8, 6, 4, 2],capacityA = 10,capacityB = 8) == 2\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 5,capacityB = 5) == 8\n assert candidate(plants = [1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 3\n assert candidate(plants = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],capacityA = 150,capacityB = 100) == 4\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacityA = 50,capacityB = 50) == 5\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 29\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],capacityA = 30,capacityB = 30) == 8\n assert candidate(plants = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],capacityA = 10,capacityB = 12) == 17\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 20,capacityB = 20) == 5\n assert candidate(plants = [1000000, 500000, 1000000, 500000, 1000000, 500000, 1000000, 500000, 1000000, 500000],capacityA = 1000000,capacityB = 1000000) == 8\n assert candidate(plants = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],capacityA = 15,capacityB = 15) == 18\n assert candidate(plants = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],capacityA = 20,capacityB = 30) == 9\n assert candidate(plants = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],capacityA = 10,capacityB = 10) == 12\n assert candidate(plants = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],capacityA = 55,capacityB = 65) == 8\n assert candidate(plants = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],capacityA = 5,capacityB = 5) == 22\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],capacityA = 15,capacityB = 20) == 6\n assert candidate(plants = [10, 20, 30, 40, 50, 40, 30, 20, 10],capacityA = 25,capacityB = 25) == 7\n assert candidate(plants = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],capacityA = 1000000,capacityB = 1000000) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacityA = 20,capacityB = 25) == 11\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 5,capacityB = 5) == 0\n assert candidate(plants = [1000000, 1000000, 1000000, 1000000, 1000000],capacityA = 1000000,capacityB = 1000000) == 3\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacityA = 30,capacityB = 35) == 7\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],capacityA = 50,capacityB = 60) == 16\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacityA = 100,capacityB = 100) == 11\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 10,capacityB = 10) == 12\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacityA = 10,capacityB = 10) == 16\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacityA = 10,capacityB = 35) == 9\n assert candidate(plants = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 15,capacityB = 20) == 6\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 10,capacityB = 5) == 7\n assert candidate(plants = [100, 150, 200, 250, 300, 350, 400, 450, 500],capacityA = 200,capacityB = 300) == 8\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 28\n assert candidate(plants = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 10,capacityB = 10) == 16\n assert candidate(plants = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],capacityA = 50,capacityB = 50) == 8\n assert candidate(plants = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],capacityA = 150,capacityB = 150) == 8\n assert candidate(plants = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984, 999983, 999982, 999981],capacityA = 2000000,capacityB = 2000000) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacityA = 20,capacityB = 10) == 13\n assert candidate(plants = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],capacityA = 150,capacityB = 120) == 4\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],capacityA = 15,capacityB = 15) == 19\n assert candidate(plants = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],capacityA = 30,capacityB = 60) == 8\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 2,capacityB = 2) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],capacityA = 7,capacityB = 8) == 12\n assert candidate(plants = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250],capacityA = 500,capacityB = 500) == 11\n assert candidate(plants = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],capacityA = 25,capacityB = 25) == 7\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacityA = 10,capacityB = 10) == 16\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],capacityA = 25,capacityB = 30) == 19\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 5,capacityB = 5) == 28\n assert candidate(plants = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],capacityA = 50,capacityB = 50) == 115\n assert candidate(plants = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61],capacityA = 1000000,capacityB = 500000) == 1\n assert candidate(plants = [1000000, 500000, 1000000, 500000],capacityA = 1000000,capacityB = 1000000) == 2\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],capacityA = 20,capacityB = 20) == 10\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 5,capacityB = 10) == 13\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 5,capacityB = 5) == 8\n assert candidate(plants = [3, 2, 4, 1, 2, 4, 3, 1, 2, 3],capacityA = 5,capacityB = 5) == 4\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 28\n assert candidate(plants = [500, 400, 300, 200, 100, 100, 200, 300, 400, 500],capacityA = 500,capacityB = 500) == 6\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],capacityA = 15,capacityB = 15) == 7\n assert candidate(plants = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],capacityA = 100,capacityB = 100) == 18\n assert candidate(plants = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],capacityA = 500000,capacityB = 500000) == 3\n assert candidate(plants = [5, 7, 3, 8, 6, 10, 4, 9, 2, 1],capacityA = 10,capacityB = 12) == 5\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 2,capacityB = 2) == 8\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 15,capacityB = 15) == 7\n assert candidate(plants = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],capacityA = 500000,capacityB = 500000) == 10\n assert candidate(plants = [100, 200, 150, 50, 300, 250, 350, 400, 450, 500],capacityA = 500,capacityB = 600) == 4\n assert candidate(plants = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],capacityA = 2000000,capacityB = 1500000) == 6\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],capacityA = 14,capacityB = 16) == 12\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],capacityA = 25,capacityB = 20) == 10\n assert candidate(plants = [100, 200, 300, 400, 500, 400, 300, 200, 100],capacityA = 300,capacityB = 300) == 5\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacityA = 25,capacityB = 20) == 4\n assert candidate(plants = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],capacityA = 5,capacityB = 5) == 18\n assert candidate(plants = [3, 2, 4, 2, 1, 2, 4, 3, 2, 1, 3, 2, 4, 2, 1],capacityA = 5,capacityB = 5) == 7\n assert candidate(plants = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],capacityA = 500,capacityB = 400) == 8\n assert candidate(plants = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],capacityA = 1000000,capacityB = 1000000) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],capacityA = 15,capacityB = 15) == 8\n assert candidate(plants = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71],capacityA = 150,capacityB = 150) == 26\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],capacityA = 10,capacityB = 10) == 7\n assert candidate(plants = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5],capacityA = 10,capacityB = 10) == 9\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],capacityA = 25,capacityB = 25) == 14\n assert candidate(plants = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5],capacityA = 5,capacityB = 5) == 13\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacityA = 5,capacityB = 5) == 20\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],capacityA = 10,capacityB = 10) == 11\n assert candidate(plants = [5, 8, 6, 7, 5, 4, 3, 2, 1, 9],capacityA = 10,capacityB = 8) == 7\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],capacityA = 20,capacityB = 25) == 11\n assert candidate(plants = [9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 10,capacityB = 10) == 4\n assert candidate(plants = [10, 5, 15, 20, 25, 30, 35, 40, 45, 50],capacityA = 25,capacityB = 30) == 8\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 18\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 5,capacityB = 5) == 18\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],capacityA = 12,capacityB = 15) == 20\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 15,capacityB = 15) == 8\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],capacityA = 25,capacityB = 30) == 8\n assert candidate(plants = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],capacityA = 100,capacityB = 100) == 5\n", "comparison": "exact"}, "public_tests": ["[2,2,3,3]\n5\n5", "[2,2,3,3]\n3\n4", "[5]\n10\n8"], "hints": ["Try \"simulating\" the process.", "Since watering each plant takes the same amount of time, where will Alice and Bob meet if they start watering the plants simultaneously? How can you use this to optimize your solution?", "What will you do when both Alice and Bob have to water the same plant?"], "metadata": {"canonical_parameter_names": ["plants", "capacityA", "capacityB"], "leetcode_dataset_entry_point": "Solution().minimumRefill", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:41:16+00:00", "tests_total": 104, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "two-pointers", "simulation"]}, "language": "javascript", "interface": {"raw_signature": "var minimumRefill = function(plants, capacityA, capacityB) {", "container": null, "callable": "minimumRefill", "parameters": [{"name": "plants", "type": "number[]"}, {"name": "capacityA", "type": "number"}, {"name": "capacityB", "type": "number"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} @@ -400,7 +399,7 @@ {"question_id": 2203, "task_id": "minimum-weighted-subgraph-with-the-required-paths", "difficulty": "Hard", "problem_description": "You are given an integer n denoting the number of nodes of a weighted directed graph. The nodes are numbered from 0 to n - 1.\n\nYou are also given a 2D integer array edges where edges[i] = [from_i, to_i, weight_i] denotes that there exists a directed edge from from_i to to_i with weight weight_i.\n\nLastly, you are given three distinct integers src1, src2, and dest denoting three distinct nodes of the graph.\n\nReturn the minimum weight of a subgraph of the graph such that it is possible to reach dest from both src1 and src2 via a set of edges of this subgraph. In case such a subgraph does not exist, return -1.\n\nA subgraph is a graph whose vertices and edges are subsets of the original graph. The weight of a subgraph is the sum of weights of its constituent edges.\n\nExample 1:\n\nInput: n = 6, edges = [[0,2,2],[0,5,6],[1,0,3],[1,4,5],[2,1,1],[2,3,3],[2,3,4],[3,4,2],[4,5,1]], src1 = 0, src2 = 1, dest = 5\nOutput: 9\nExplanation:\nThe above figure represents the input graph.\nThe blue edges represent one of the subgraphs that yield the optimal answer.\nNote that the subgraph [[1,0,3],[0,5,6]] also yields the optimal answer. It is not possible to get a subgraph with less weight satisfying all the constraints.\n\nExample 2:\n\nInput: n = 3, edges = [[0,1,1],[2,1,1]], src1 = 0, src2 = 1, dest = 2\nOutput: -1\nExplanation:\nThe above figure represents the input graph.\nIt can be seen that there does not exist any path from node 1 to node 2, hence there are no subgraphs satisfying all the constraints.\n\nConstraints:\n\n- 3 <= n <= 10^5\n- 0 <= edges.length <= 10^5\n- edges[i].length == 3\n- 0 <= from_i, to_i, src1, src2, dest <= n - 1\n- from_i != to_i\n- src1, src2, and dest are pairwise distinct.\n- 1 <= weight[i] <= 10^5\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,edges = [[0, 2, 2], [0, 5, 6], [1, 0, 3], [1, 4, 5], [2, 1, 1], [2, 3, 3], [2, 3, 4], [3, 4, 2], [4, 5, 1]],src1 = 0,src2 = 1,dest = 5) == 9\n assert candidate(n = 6,edges = [[1, 2, 2], [1, 3, 1], [2, 4, 5], [3, 4, 3], [4, 5, 2]],src1 = 1,src2 = 2,dest = 5) == 9\n assert candidate(n = 3,edges = [[0, 1, 1], [2, 1, 1]],src1 = 0,src2 = 1,dest = 2) == -1\n assert candidate(n = 5,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 0, 50]],src1 = 0,src2 = 2,dest = 4) == 100\n assert candidate(n = 4,edges = [[0, 1, 2], [0, 2, 2], [1, 3, 1], [2, 3, 1]],src1 = 0,src2 = 1,dest = 3) == 3\n assert candidate(n = 5,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 0, 5]],src1 = 0,src2 = 1,dest = 4) == 10\n assert candidate(n = 5,edges = [[0, 1, 10], [0, 2, 5], [1, 3, 1], [1, 4, 2], [2, 3, 4], [2, 4, 3]],src1 = 0,src2 = 1,dest = 4) == 10\n assert candidate(n = 5,edges = [[0, 1, 10], [0, 2, 3], [1, 3, 2], [2, 1, 4], [2, 3, 8], [2, 4, 2]],src1 = 0,src2 = 2,dest = 3) == 9\n assert candidate(n = 4,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 1, 4]],src1 = 0,src2 = 2,dest = 3) == 6\n assert candidate(n = 5,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [2, 3, 1], [2, 4, 4]],src1 = 0,src2 = 2,dest = 3) == 4\n assert candidate(n = 4,edges = [[0, 1, 2], [0, 2, 4], [1, 3, 1], [2, 3, 3]],src1 = 0,src2 = 1,dest = 3) == 3\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 1], [1, 4, 2], [2, 5, 1], [2, 6, 2], [3, 6, 1], [4, 6, 2]],src1 = 0,src2 = 1,dest = 6) == 3\n assert candidate(n = 12,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12]],src1 = 0,src2 = 6,dest = 11) == 66\n assert candidate(n = 10,edges = [[0, 1, 20], [0, 2, 30], [1, 3, 40], [1, 4, 50], [2, 4, 60], [2, 5, 70], [3, 6, 80], [3, 7, 90], [4, 7, 100], [4, 8, 110], [5, 8, 120], [5, 9, 130], [6, 9, 140], [7, 9, 150]],src1 = 0,src2 = 2,dest = 9) == 230\n assert candidate(n = 6,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [2, 4, 4], [3, 5, 5], [4, 5, 6]],src1 = 0,src2 = 1,dest = 5) == 9\n assert candidate(n = 20,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 0, 20], [0, 10, 1], [1, 11, 2], [2, 12, 3], [3, 13, 4], [4, 14, 5], [5, 15, 6], [6, 16, 7], [7, 17, 8], [8, 18, 9], [9, 19, 10], [10, 0, 11], [11, 1, 12], [12, 2, 13], [13, 3, 14], [14, 4, 15], [15, 5, 16], [16, 6, 17], [17, 7, 18], [18, 8, 19], [19, 9, 20]],src1 = 0,src2 = 2,dest = 19) == 55\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 5], [2, 4, 6], [3, 5, 7], [3, 6, 8], [4, 5, 9], [4, 6, 10], [5, 7, 11], [6, 7, 12]],src1 = 0,src2 = 3,dest = 7) == 22\n assert candidate(n = 15,edges = [[0, 1, 2], [0, 2, 4], [1, 3, 3], [1, 4, 1], [2, 3, 1], [2, 4, 5], [3, 5, 2], [4, 5, 3], [5, 6, 4], [6, 7, 1], [7, 8, 3], [8, 9, 2], [9, 10, 4], [10, 11, 5], [11, 12, 6], [12, 13, 7], [13, 14, 8]],src1 = 0,src2 = 1,dest = 14) == 46\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 8, 9], [6, 7, 10]],src1 = 0,src2 = 2,dest = 8) == 16\n assert candidate(n = 12,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 5], [2, 4, 6], [3, 5, 7], [3, 6, 8], [4, 5, 9], [4, 6, 10], [5, 7, 11], [6, 7, 12], [7, 8, 13], [8, 9, 14], [8, 10, 15], [9, 11, 16], [10, 11, 17]],src1 = 0,src2 = 5,dest = 11) == 65\n assert candidate(n = 12,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12], [0, 5, 1], [1, 6, 2], [2, 7, 3], [3, 8, 4], [4, 9, 5], [5, 10, 6], [6, 11, 7], [7, 0, 8], [8, 1, 9], [9, 2, 10], [10, 3, 11], [11, 4, 12]],src1 = 0,src2 = 2,dest = 11) == 21\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 5], [2, 4, 6], [3, 5, 7], [3, 6, 8], [4, 5, 9], [4, 6, 10], [5, 7, 11], [6, 7, 12], [7, 8, 13]],src1 = 0,src2 = 4,dest = 8) == 38\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 2], [2, 4, 3], [3, 5, 1], [3, 6, 2], [4, 5, 2], [4, 6, 3], [5, 7, 1], [6, 7, 2]],src1 = 0,src2 = 2,dest = 7) == 6\n assert candidate(n = 7,edges = [[0, 1, 3], [0, 2, 5], [1, 2, 2], [1, 3, 8], [2, 3, 4], [2, 4, 9], [3, 4, 1], [3, 5, 6], [4, 5, 7], [4, 6, 10], [5, 6, 5]],src1 = 0,src2 = 2,dest = 6) == 20\n assert candidate(n = 7,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [1, 4, 5], [2, 3, 1], [2, 5, 7], [3, 6, 3], [4, 6, 2], [5, 6, 6]],src1 = 0,src2 = 2,dest = 6) == 7\n assert candidate(n = 10,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 9, 15], [1, 8, 14], [2, 7, 13], [3, 6, 12], [4, 5, 11]],src1 = 0,src2 = 1,dest = 9) == 24\n assert candidate(n = 8,edges = [[0, 1, 2], [0, 2, 4], [1, 3, 3], [1, 4, 5], [2, 4, 1], [2, 5, 6], [3, 6, 7], [4, 6, 8], [4, 7, 9], [5, 7, 3], [6, 7, 10]],src1 = 0,src2 = 1,dest = 7) == 16\n assert candidate(n = 12,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12], [11, 0, 13], [0, 5, 1], [1, 6, 2], [2, 7, 3], [3, 8, 4], [4, 9, 5], [5, 10, 6], [6, 11, 7], [7, 0, 8], [8, 1, 9], [9, 2, 10], [10, 3, 11], [11, 4, 12]],src1 = 0,src2 = 6,dest = 11) == 11\n assert candidate(n = 8,edges = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 0, 40], [0, 3, 2], [1, 4, 3], [2, 5, 4], [3, 6, 5], [4, 7, 6]],src1 = 0,src2 = 1,dest = 7) == 14\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [0, 3, 5], [1, 4, 6], [2, 5, 7], [3, 6, 8], [4, 7, 9], [5, 8, 10], [6, 9, 11]],src1 = 0,src2 = 2,dest = 9) == 25\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 7, 8], [5, 7, 9], [6, 7, 10]],src1 = 0,src2 = 1,dest = 7) == 11\n assert candidate(n = 8,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [1, 4, 40], [2, 5, 50], [2, 6, 60], [3, 7, 70], [4, 7, 80], [5, 7, 90], [6, 7, 100]],src1 = 0,src2 = 2,dest = 7) == 160\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 5], [2, 4, 6], [3, 5, 7], [4, 5, 8], [5, 6, 9]],src1 = 0,src2 = 1,dest = 6) == 20\n assert candidate(n = 10,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10]],src1 = 0,src2 = 5,dest = 9) == 45\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 3, 5], [2, 5, 6], [3, 6, 7], [3, 7, 8], [4, 7, 9], [4, 8, 10], [5, 8, 11], [6, 8, 12]],src1 = 0,src2 = 2,dest = 8) == 19\n assert candidate(n = 15,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15]],src1 = 0,src2 = 7,dest = 14) == 105\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 1], [1, 4, 4], [2, 1, 2], [2, 3, 6], [3, 4, 2], [4, 5, 7], [5, 6, 1], [6, 7, 2], [7, 8, 3], [8, 9, 1]],src1 = 0,src2 = 2,dest = 9) == 22\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [1, 4, 4], [2, 5, 6], [2, 6, 7], [3, 7, 8], [4, 8, 1], [5, 9, 2], [6, 9, 3], [7, 9, 9], [8, 9, 6]],src1 = 0,src2 = 2,dest = 9) == 11\n assert candidate(n = 11,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [1, 4, 40], [2, 4, 50], [2, 5, 60], [3, 6, 70], [3, 7, 80], [4, 7, 90], [4, 8, 100], [5, 8, 110], [5, 9, 120], [6, 9, 130], [6, 10, 140], [7, 10, 150], [8, 10, 160]],src1 = 0,src2 = 2,dest = 10) == 310\n assert candidate(n = 15,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [1, 4, 5], [2, 5, 6], [2, 6, 7], [3, 7, 8], [3, 8, 9], [4, 8, 10], [4, 9, 11], [5, 9, 12], [5, 10, 13], [6, 10, 14], [6, 11, 15], [7, 11, 16], [7, 12, 17], [8, 12, 18], [9, 12, 19], [10, 13, 20], [11, 13, 21], [12, 14, 22]],src1 = 0,src2 = 5,dest = 14) == 62\n assert candidate(n = 15,edges = [[0, 1, 10], [0, 5, 20], [1, 2, 5], [1, 3, 15], [2, 4, 10], [3, 6, 20], [4, 7, 5], [5, 8, 15], [6, 9, 20], [7, 10, 10], [8, 11, 20], [9, 12, 25], [10, 13, 15], [11, 14, 25], [12, 13, 5], [13, 14, 20]],src1 = 0,src2 = 5,dest = 14) == 80\n assert candidate(n = 7,edges = [[0, 1, 10], [0, 2, 5], [1, 3, 1], [1, 4, 2], [2, 5, 4], [2, 6, 5], [3, 4, 3], [4, 5, 2], [5, 6, 1]],src1 = 0,src2 = 1,dest = 6) == 14\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 7, 8], [5, 7, 9], [6, 7, 10], [3, 4, 11], [5, 6, 12]],src1 = 0,src2 = 2,dest = 7) == 16\n assert candidate(n = 15,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 1], [1, 4, 2], [2, 5, 4], [2, 6, 5], [3, 7, 6], [4, 8, 7], [5, 9, 8], [6, 10, 9], [7, 11, 10], [8, 12, 11], [9, 13, 12], [10, 14, 13], [11, 14, 14]],src1 = 0,src2 = 1,dest = 14) == 33\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 8, 10], [7, 9, 11], [8, 9, 12]],src1 = 0,src2 = 2,dest = 9) == 16\n assert candidate(n = 15,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 10, 10], [7, 11, 11], [8, 12, 12], [9, 13, 13], [10, 14, 14], [11, 14, 15], [12, 14, 16]],src1 = 0,src2 = 2,dest = 14) == 32\n assert candidate(n = 7,edges = [[0, 1, 5], [0, 2, 10], [1, 3, 3], [1, 4, 4], [2, 1, 6], [2, 4, 8], [2, 5, 7], [3, 6, 2], [4, 6, 5], [5, 6, 1]],src1 = 0,src2 = 2,dest = 6) == 16\n assert candidate(n = 15,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 10, 10], [7, 11, 11], [8, 12, 12], [9, 13, 13], [10, 14, 14], [11, 12, 15], [12, 13, 16], [13, 14, 17]],src1 = 0,src2 = 1,dest = 14) == 58\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 9, 10]],src1 = 0,src2 = 1,dest = 9) == -1\n assert candidate(n = 10,edges = [[0, 1, 2], [0, 2, 4], [1, 3, 1], [1, 4, 3], [2, 5, 2], [2, 6, 5], [3, 7, 1], [4, 7, 2], [5, 8, 3], [6, 8, 4], [7, 9, 5], [8, 9, 6]],src1 = 0,src2 = 2,dest = 9) == 15\n assert candidate(n = 7,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [1, 4, 6], [2, 3, 5], [2, 5, 1], [3, 6, 3], [4, 6, 2], [5, 6, 7]],src1 = 0,src2 = 1,dest = 6) == 9\n assert candidate(n = 7,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 0, 7], [0, 6, 8], [1, 5, 9], [2, 4, 10]],src1 = 0,src2 = 3,dest = 6) == 21\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [1, 4, 4], [2, 3, 1], [2, 5, 7], [3, 6, 3], [4, 6, 2], [5, 7, 6], [6, 8, 2], [7, 8, 5], [8, 9, 10]],src1 = 0,src2 = 1,dest = 9) == 21\n assert candidate(n = 12,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 10, 10], [7, 11, 11], [8, 11, 12], [9, 11, 13], [10, 11, 14]],src1 = 0,src2 = 2,dest = 11) == 29\n assert candidate(n = 6,edges = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 0, 600]],src1 = 0,src2 = 3,dest = 5) == 1500\n assert candidate(n = 20,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [0, 19, 1]],src1 = 0,src2 = 10,dest = 19) == 136\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 3], [1, 3, 2], [1, 4, 4], [2, 1, 4], [2, 3, 8], [2, 4, 2], [3, 5, 1], [4, 5, 3], [5, 6, 2], [6, 7, 1], [7, 8, 3], [8, 9, 2], [9, 6, 4]],src1 = 0,src2 = 2,dest = 8) == 14\n assert candidate(n = 6,edges = [[0, 1, 1000], [1, 2, 2000], [2, 3, 3000], [3, 4, 4000], [4, 5, 5000], [5, 0, 6000], [0, 2, 1500], [1, 3, 2500], [2, 4, 3500], [3, 5, 4500]],src1 = 0,src2 = 1,dest = 5) == 8000\n", "comparison": "exact"}, "public_tests": ["6\n[[0,2,2],[0,5,6],[1,0,3],[1,4,5],[2,1,1],[2,3,3],[2,3,4],[3,4,2],[4,5,1]]\n0\n1\n5", "3\n[[0,1,1],[2,1,1]]\n0\n1\n2"], "hints": ["Consider what the paths from src1 to dest and src2 to dest would look like in the optimal solution.", "It can be shown that in an optimal solution, the two paths from src1 and src2 will coincide at one node, and the remaining part to dest will be the same for both paths. Now consider how to find the node where the paths will coincide.", "How can algorithms for finding the shortest path between two nodes help us?"], "metadata": {"canonical_parameter_names": ["n", "edges", "src1", "src2", "dest"], "leetcode_dataset_entry_point": "Solution().minimumWeight", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:48+00:00", "tests_total": 58, "tests_dropped": 0, "flags": ["has_images"], "topic_tags": ["graph", "heap-priority-queue", "shortest-path"]}, "language": "javascript", "interface": {"raw_signature": "var minimumWeight = function(n, edges, src1, src2, dest) {", "container": null, "callable": "minimumWeight", "parameters": [{"name": "n", "type": "number"}, {"name": "edges", "type": "number[][]"}, {"name": "src1", "type": "number"}, {"name": "src2", "type": "number"}, {"name": "dest", "type": "number"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2206, "task_id": "divide-array-into-equal-pairs", "difficulty": "Easy", "problem_description": "You are given an integer array nums consisting of 2 * n integers.\n\nYou need to divide nums into n pairs such that:\n\n- Each element belongs to exactly one pair.\n- The elements present in a pair are equal.\n\nReturn true if nums can be divided into n pairs, otherwise return false.\n\nExample 1:\n\nInput: nums = [3,2,3,2,2,2]\nOutput: true\nExplanation:\nThere are 6 elements in nums, so they should be divided into 6 / 2 = 3 pairs.\nIf nums is divided into the pairs (2, 2), (3, 3), and (2, 2), it will satisfy all the conditions.\n\nExample 2:\n\nInput: nums = [1,2,3,4]\nOutput: false\nExplanation:\nThere is no way to divide nums into 4 / 2 = 2 pairs such that the pairs satisfy every condition.\n\nConstraints:\n\n- nums.length == 2 * n\n- 1 <= n <= 500\n- 1 <= nums[i] <= 500\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4]) == True\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2]) == True\n assert candidate(nums = [1, 2, 1, 3, 2, 3]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == True\n assert candidate(nums = [100, 100, 200, 200, 300, 300]) == True\n assert candidate(nums = [100, 200, 100, 200, 100, 200]) == False\n assert candidate(nums = [4, 4, 5, 5, 6, 6, 7, 7]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3]) == True\n assert candidate(nums = [1, 2, 3, 4]) == False\n assert candidate(nums = [4, 4, 5, 5, 6, 6]) == True\n assert candidate(nums = [5, 5, 6, 6, 7, 7, 8, 8]) == True\n assert candidate(nums = [499, 499, 500, 500, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 3, 2]) == False\n assert candidate(nums = [2, 3, 2, 3, 2, 3]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == False\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == True\n assert candidate(nums = [10, 10, 10, 10, 10, 10]) == True\n assert candidate(nums = [3, 2, 3, 2, 2, 2]) == True\n assert candidate(nums = [8, 8, 8, 8, 9, 9, 9, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == False\n assert candidate(nums = [7, 7, 8, 8, 9, 9, 10, 10]) == True\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [500, 500, 499, 499, 498, 498]) == True\n assert candidate(nums = [1, 2, 1, 2, 3, 3]) == True\n assert candidate(nums = [499, 499, 498, 498, 497, 497]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499, 499]) == True\n assert candidate(nums = [499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491, 490, 490]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == True\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == True\n assert candidate(nums = [50, 50, 50, 50, 20, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 10, 10, 10, 10, 60, 60, 60, 60, 70, 70, 70, 70]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == False\n assert candidate(nums = [250, 250, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50]) == True\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8]) == True\n assert candidate(nums = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n assert candidate(nums = [100, 100, 101, 101, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107]) == True\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491, 490, 490, 489, 489, 488, 488, 487, 487, 486, 486]) == True\n assert candidate(nums = [450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450, 450]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6]) == False\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100, 110, 110, 120, 120, 130, 130, 140, 140, 150, 150]) == True\n assert candidate(nums = [100, 100, 200, 200, 300, 300, 400, 400, 500, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == True\n assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491, 490, 490, 489, 489, 488, 488, 487, 487, 486, 486, 485, 485, 484, 484, 483, 483, 482, 482, 481, 481, 480, 480]) == True\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100, 110, 110, 120, 120]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 12, 13, 13]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491]) == True\n assert candidate(nums = [100, 100, 101, 101, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113]) == True\n assert candidate(nums = [3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 7, 7, 7, 7, 9, 9, 9, 9, 8, 8, 8, 8, 6, 6, 6, 6, 4, 4, 4, 4]) == True\n assert candidate(nums = [10, 10, 20, 20, 20, 20, 30, 30, 30, 30, 30, 30]) == True\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == False\n assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491, 490, 490, 489, 489, 488, 488, 487, 487, 486, 486, 485, 485]) == True\n assert candidate(nums = [100, 100, 101, 101, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120]) == True\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == True\n assert candidate(nums = [499, 499, 498, 498, 497, 497, 496, 496, 495, 495, 494, 494, 493, 493, 492, 492, 491, 491, 490, 490]) == True\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == True\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n assert candidate(nums = [250, 250, 251, 251, 252, 252, 253, 253, 254, 254, 255, 255, 256, 256, 257, 257, 258, 258, 259, 259, 260, 260]) == True\n assert candidate(nums = [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [100, 100, 100, 100, 101, 101, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108]) == True\n assert candidate(nums = [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == False\n", "comparison": "exact"}, "public_tests": ["[3,2,3,2,2,2]", "[1,2,3,4]"], "hints": ["For any number x in the range [1, 500], count the number of elements in nums whose values are equal to x.", "The elements with equal value can be divided completely into pairs if and only if their count is even."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().divideArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:52+00:00", "tests_total": 91, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "hash-table", "bit-manipulation", "counting"]}, "language": "javascript", "interface": {"raw_signature": "var divideArray = function(nums) {", "container": null, "callable": "divideArray", "parameters": [{"name": "nums", "type": "number[]"}], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2207, "task_id": "maximize-number-of-subsequences-in-a-string", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string text and another 0-indexed string pattern of length 2, both of which consist of only lowercase English letters.\n\nYou can add either pattern[0] or pattern[1] anywhere in text exactly once. Note that the character can be added even at the beginning or at the end of text.\n\nReturn the maximum number of times pattern can occur as a subsequence of the modified text.\n\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\n\nExample 1:\n\nInput: text = \"abdcdbc\", pattern = \"ac\"\nOutput: 4\nExplanation:\nIf we add pattern[0] = 'a' in between text[1] and text[2], we get \"abadcdbc\". Now, the number of times \"ac\" occurs as a subsequence is 4.\nSome other strings which have 4 subsequences \"ac\" after adding a character to text are \"aabdcdbc\" and \"abdacdbc\".\nHowever, strings such as \"abdcadbc\", \"abdccdbc\", and \"abdcdbcc\", although obtainable, have only 3 subsequences \"ac\" and are thus suboptimal.\nIt can be shown that it is not possible to get more than 4 subsequences \"ac\" by adding only one character.\n\nExample 2:\n\nInput: text = \"aabb\", pattern = \"ab\"\nOutput: 6\nExplanation:\nSome of the strings which can be obtained from text and have 6 subsequences \"ab\" are \"aaabb\", \"aaabb\", and \"aabbb\".\n\nConstraints:\n\n- 1 <= text.length <= 10^5\n- pattern.length == 2\n- text and pattern consist only of lowercase English letters.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"bbbb\",pattern = \"bb\") == 10\n assert candidate(text = \"aaaaa\",pattern = \"aa\") == 15\n assert candidate(text = \"zzzz\",pattern = \"zz\") == 10\n assert candidate(text = \"abdcdbc\",pattern = \"ac\") == 4\n assert candidate(text = \"abc\",pattern = \"ca\") == 1\n assert candidate(text = \"babab\",pattern = \"ba\") == 6\n assert candidate(text = \"zzz\",pattern = \"zz\") == 6\n assert candidate(text = \"abcabc\",pattern = \"aa\") == 3\n assert candidate(text = \"a\",pattern = \"ab\") == 1\n assert candidate(text = \"ab\",pattern = \"ba\") == 1\n assert candidate(text = \"aabb\",pattern = \"ab\") == 6\n assert candidate(text = \"aaa\",pattern = \"aa\") == 6\n assert candidate(text = \"b\",pattern = \"ab\") == 1\n assert candidate(text = \"aaaa\",pattern = \"aa\") == 10\n assert candidate(text = \"xyzxyz\",pattern = \"yx\") == 3\n assert candidate(text = \"abcabc\",pattern = \"ac\") == 5\n assert candidate(text = \"xyz\",pattern = \"xz\") == 2\n assert candidate(text = \"abxyabxyabxy\",pattern = \"bx\") == 9\n assert candidate(text = \"zxyzxyzxyz\",pattern = \"yz\") == 10\n assert candidate(text = \"xyzyzyzyzyzx\",pattern = \"yx\") == 10\n assert candidate(text = \"zzzzzzzzzzz\",pattern = \"zz\") == 66\n assert candidate(text = \"pqrsrstq\",pattern = \"pq\") == 4\n assert candidate(text = \"bbabbaaa\",pattern = \"ba\") == 18\n assert candidate(text = \"ababababab\",pattern = \"ba\") == 15\n assert candidate(text = \"aaaaabbbbb\",pattern = \"ab\") == 30\n assert candidate(text = \"aaabbbccc\",pattern = \"ac\") == 12\n assert candidate(text = \"abacabacaba\",pattern = \"ac\") == 12\n assert candidate(text = \"abcdefabcdef\",pattern = \"cf\") == 5\n assert candidate(text = \"bbaabb\",pattern = \"ba\") == 8\n assert candidate(text = \"bcbcbcbcbb\",pattern = \"bc\") == 16\n assert candidate(text = \"bbaabaabaabbb\",pattern = \"ab\") == 31\n assert candidate(text = \"bbbbba\",pattern = \"ba\") == 10\n assert candidate(text = \"acbacbacba\",pattern = \"ac\") == 10\n assert candidate(text = \"mnopqr\",pattern = \"pq\") == 2\n assert candidate(text = \"xyxzyxzyxzyx\",pattern = \"yx\") == 15\n assert candidate(text = \"zzyzxzyzxzy\",pattern = \"yz\") == 12\n assert candidate(text = \"xyyxxyyxxyy\",pattern = \"yx\") == 18\n assert candidate(text = \"aabbccdd\",pattern = \"ac\") == 6\n assert candidate(text = \"abcdabcdabcd\",pattern = \"ac\") == 9\n assert candidate(text = \"mississippi\",pattern = \"is\") == 10\n assert candidate(text = \"zzzzzzzzzz\",pattern = \"zz\") == 55\n assert candidate(text = \"ababababab\",pattern = \"ab\") == 20\n assert candidate(text = \"aabbaabbaabbaabbaabbaabbaabbaabb\",pattern = \"bb\") == 136\n assert candidate(text = \"qwertyuiop\",pattern = \"qp\") == 2\n assert candidate(text = \"aaaaaaa\",pattern = \"aa\") == 28\n assert candidate(text = \"abcdabcdabcd\",pattern = \"da\") == 6\n assert candidate(text = \"zzzzz\",pattern = \"zz\") == 15\n assert candidate(text = \"abababababab\",pattern = \"ba\") == 21\n assert candidate(text = \"abababababa\",pattern = \"ab\") == 21\n assert candidate(text = \"abcabcabcabc\",pattern = \"ac\") == 14\n assert candidate(text = \"aabbbcc\",pattern = \"ac\") == 6\n assert candidate(text = \"aabbaabbaabbaabbaabb\",pattern = \"aa\") == 55\n assert candidate(text = \"babcbabcba\",pattern = \"bc\") == 11\n assert candidate(text = \"aabbccddeeff\",pattern = \"bf\") == 6\n assert candidate(text = \"abcabcabc\",pattern = \"ab\") == 9\n assert candidate(text = \"bcbcbcbcbc\",pattern = \"bc\") == 20\n assert candidate(text = \"xyxxyxyxyx\",pattern = \"yx\") == 17\n assert candidate(text = \"abcabcabcabcabcabc\",pattern = \"ca\") == 21\n assert candidate(text = \"xzyxzyxzyz\",pattern = \"zy\") == 10\n assert candidate(text = \"zzzzzz\",pattern = \"zz\") == 21\n assert candidate(text = \"aabbbaaabbbb\",pattern = \"ab\") == 33\n assert candidate(text = \"aaabbb\",pattern = \"ab\") == 12\n assert candidate(text = \"nnaaaannaa\",pattern = \"an\") == 14\n assert candidate(text = \"xyxyxyxyxy\",pattern = \"yx\") == 15\n assert candidate(text = \"cccccc\",pattern = \"cc\") == 21\n assert candidate(text = \"abacabadabacaba\",pattern = \"ba\") == 24\n assert candidate(text = \"bababababababababa\",pattern = \"bb\") == 45\n assert candidate(text = \"dcbabcdabcba\",pattern = \"ab\") == 9\n assert candidate(text = \"xyzzyxzyxzyxzyx\",pattern = \"zy\") == 19\n assert candidate(text = \"aaaaaabbbb\",pattern = \"ab\") == 30\n assert candidate(text = \"cccccccc\",pattern = \"cc\") == 36\n assert candidate(text = \"babcbacbab\",pattern = \"bc\") == 10\n assert candidate(text = \"abcdefghijklmnopqrstuvwxyz\",pattern = \"zy\") == 1\n assert candidate(text = \"zzzyyy\",pattern = \"yz\") == 3\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\",pattern = \"zz\") == 406\n assert candidate(text = \"mnopqrqpomn\",pattern = \"mn\") == 5\n assert candidate(text = \"aabbaabb\",pattern = \"bb\") == 10\n assert candidate(text = \"aabbccddeeffgg\",pattern = \"ag\") == 6\n assert candidate(text = \"ccbaaa\",pattern = \"ab\") == 3\n assert candidate(text = \"xyzzyxzyzxzyxzyx\",pattern = \"yz\") == 20\n assert candidate(text = \"aaaaaaaaa\",pattern = \"aa\") == 45\n assert candidate(text = \"aabbaabb\",pattern = \"ab\") == 16\n assert candidate(text = \"bababababababa\",pattern = \"ba\") == 35\n assert candidate(text = \"bababababa\",pattern = \"ba\") == 20\n assert candidate(text = \"zyxwvutsrqponmlkjihgfedcba\",pattern = \"yz\") == 1\n assert candidate(text = \"qqqqqqqqqq\",pattern = \"qp\") == 10\n assert candidate(text = \"qwertyuiopasdfghjklzxcvbnm\",pattern = \"mn\") == 1\n assert candidate(text = \"abcabcdabc\",pattern = \"bc\") == 9\n assert candidate(text = \"zzzzyyyy\",pattern = \"zy\") == 20\n assert candidate(text = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",pattern = \"xz\") == 6\n assert candidate(text = \"abacabacab\",pattern = \"ac\") == 11\n assert candidate(text = \"fedcba\",pattern = \"ab\") == 1\n assert candidate(text = \"ccccbbbaaa\",pattern = \"ba\") == 12\n assert candidate(text = \"mmnnnmmnnm\",pattern = \"mn\") == 19\n assert candidate(text = \"abcabcabc\",pattern = \"ba\") == 6\n assert candidate(text = \"xyzxyzxyzxyz\",pattern = \"yx\") == 10\n assert candidate(text = \"qqqqqppppp\",pattern = \"pq\") == 5\n assert candidate(text = \"aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbb\",pattern = \"ba\") == 20\n assert candidate(text = \"abbaba\",pattern = \"ab\") == 7\n assert candidate(text = \"zzzzzzzzzzzzz\",pattern = \"zz\") == 91\n assert candidate(text = \"zzyzxzyzxzyz\",pattern = \"yz\") == 16\n assert candidate(text = \"aabbaabb\",pattern = \"aa\") == 10\n assert candidate(text = \"abcabcabcabcabc\",pattern = \"ab\") == 20\n assert candidate(text = \"babbabababababababa\",pattern = \"ba\") == 63\n assert candidate(text = \"aaabbbcccddd\",pattern = \"ad\") == 12\n assert candidate(text = \"abcdef\",pattern = \"fe\") == 1\n assert candidate(text = \"bbbbbbbbbb\",pattern = \"bb\") == 55\n assert candidate(text = \"bbbbbaaaaa\",pattern = \"ab\") == 5\n assert candidate(text = \"abcde\",pattern = \"ae\") == 2\n assert candidate(text = \"abracadabra\",pattern = \"ra\") == 10\n assert candidate(text = \"abcdefghij\",pattern = \"ae\") == 2\n assert candidate(text = \"aaabbbccc\",pattern = \"ab\") == 12\n assert candidate(text = \"abcdefghij\",pattern = \"aj\") == 2\n assert candidate(text = \"xyzzyxzyxzyxzyxzyxzyxzyx\",pattern = \"zx\") == 43\n assert candidate(text = \"mmnmmnmmn\",pattern = \"mn\") == 18\n assert candidate(text = \"aabbccddeeff\",pattern = \"ef\") == 6\n assert candidate(text = \"zzzzzzzz\",pattern = \"zz\") == 36\n assert candidate(text = \"ccccccc\",pattern = \"cc\") == 28\n assert candidate(text = \"abcabcabc\",pattern = \"bc\") == 9\n assert candidate(text = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",pattern = \"az\") == 6\n assert candidate(text = \"abcdefghij\",pattern = \"af\") == 2\n assert candidate(text = \"bbbbbaaaaa\",pattern = \"ba\") == 30\n assert candidate(text = \"xyzyxzyxzy\",pattern = \"yx\") == 9\n assert candidate(text = \"aabccbaa\",pattern = \"ac\") == 8\n assert candidate(text = \"abacabadabacaba\",pattern = \"ab\") == 24\n assert candidate(text = \"aabccccdddd\",pattern = \"cd\") == 20\n assert candidate(text = \"aaaaaaaaaa\",pattern = \"aa\") == 55\n assert candidate(text = \"aaaabbbb\",pattern = \"ab\") == 20\n assert candidate(text = \"aaaaaaaaaaaabbbbbbbbbbbb\",pattern = \"ab\") == 156\n assert candidate(text = \"abcdefghijklnmopqrstuvwxyz\",pattern = \"az\") == 2\n assert candidate(text = \"abcd\",pattern = \"da\") == 1\n assert candidate(text = \"abcdabcdabcd\",pattern = \"ad\") == 9\n assert candidate(text = \"lkjqwpmr\",pattern = \"qw\") == 2\n assert candidate(text = \"aabbaabbcc\",pattern = \"ab\") == 16\n assert candidate(text = \"abcabcabc\",pattern = \"ac\") == 9\n assert candidate(text = \"baabbaab\",pattern = \"ba\") == 12\n", "comparison": "exact"}, "public_tests": ["\"abdcdbc\"\n\"ac\"", "\"aabb\"\n\"ab\""], "hints": ["Find the optimal position to add pattern[0] so that the number of subsequences is maximized. Similarly, find the optimal position to add pattern[1].", "For each of the above cases, count the number of times the pattern occurs as a subsequence in text. The larger count is the required answer."], "metadata": {"canonical_parameter_names": ["text", "pattern"], "leetcode_dataset_entry_point": "Solution().maximumSubsequenceCount", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:55+00:00", "tests_total": 138, "tests_dropped": 2, "flags": [], "topic_tags": ["string", "greedy", "prefix-sum"]}, "language": "javascript", "interface": {"raw_signature": "var maximumSubsequenceCount = function(text, pattern) {", "container": null, "callable": "maximumSubsequenceCount", "parameters": [{"name": "text", "type": "string"}, {"name": "pattern", "type": "string"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2208, "task_id": "minimum-operations-to-halve-array-sum", "difficulty": "Medium", "problem_description": "You are given an array nums of positive integers. In one operation, you can choose any number from nums and reduce it to exactly half the number. (Note that you may choose this reduced number in future operations.)\n\nReturn the minimum number of operations to reduce the sum of nums by at least half.\n\nExample 1:\n\nInput: nums = [5,19,8,1]\nOutput: 3\nExplanation: The initial sum of nums is equal to 5 + 19 + 8 + 1 = 33.\nThe following is one of the ways to reduce the sum by at least half:\nPick the number 19 and reduce it to 9.5.\nPick the number 9.5 and reduce it to 4.75.\nPick the number 8 and reduce it to 4.\nThe final array is [5, 4.75, 4, 1] with a total sum of 5 + 4.75 + 4 + 1 = 14.75.\nThe sum of nums has been reduced by 33 - 14.75 = 18.25, which is at least half of the initial sum, 18.25 >= 33/2 = 16.5.\nOverall, 3 operations were used so we return 3.\nIt can be shown that we cannot reduce the sum by at least half in less than 3 operations.\n\nExample 2:\n\nInput: nums = [3,8,20]\nOutput: 3\nExplanation: The initial sum of nums is equal to 3 + 8 + 20 = 31.\nThe following is one of the ways to reduce the sum by at least half:\nPick the number 20 and reduce it to 10.\nPick the number 10 and reduce it to 5.\nPick the number 3 and reduce it to 1.5.\nThe final array is [1.5, 8, 5] with a total sum of 1.5 + 8 + 5 = 14.5.\nThe sum of nums has been reduced by 31 - 14.5 = 16.5, which is at least half of the initial sum, 16.5 >= 31/2 = 15.5.\nOverall, 3 operations were used so we return 3.\nIt can be shown that we cannot reduce the sum by at least half in less than 3 operations.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [100, 100, 100, 100]) == 4\n assert candidate(nums = [3, 8, 20]) == 3\n assert candidate(nums = [10000000]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [5, 19, 8, 1]) == 3\n assert candidate(nums = [10, 20, 30, 40, 50]) == 5\n assert candidate(nums = [10, 10, 10, 10, 10]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 10\n assert candidate(nums = [10, 20, 30, 40]) == 4\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 3\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == 13\n assert candidate(nums = [9999999, 9999998, 9999997, 9999996, 9999995]) == 5\n assert candidate(nums = [5000000, 5000000, 5000000, 5000000, 5000000]) == 5\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953]) == 3\n assert candidate(nums = [1000, 500, 250, 125, 62.5, 31.25]) == 3\n assert candidate(nums = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250]) == 3\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584]) == 3\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 24\n assert candidate(nums = [1, 1000000, 100000, 10000, 1000]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 9\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 3\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 9\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 16\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 3\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 3\n assert candidate(nums = [5000000, 3000000, 2000000, 1000000, 500000, 300000, 200000, 100000]) == 4\n assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 30\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 15\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250]) == 3\n assert candidate(nums = [1234567, 2345678, 3456789, 4567890, 5678901, 6789012, 7890123, 8901234, 9012345]) == 8\n assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500]) == 16\n assert candidate(nums = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062, 19531]) == 3\n assert candidate(nums = [9999999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000]) == 4\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1]) == 10\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 18\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 3\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 9\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062, 19531, 9765, 4882, 2441, 1220, 610, 305, 152, 76, 38]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000]) == 2\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 20\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 12\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 25\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100000]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 14\n assert candidate(nums = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062.5, 19531.25]) == 3\n assert candidate(nums = [10000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 2\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) == 2\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 20\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 20\n assert candidate(nums = [9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991, 9999990]) == 10\n assert candidate(nums = [5000000, 5000000, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [9999999, 8888888, 7777777, 6666666, 5555555, 4444444, 3333333, 2222222, 1111111]) == 8\n assert candidate(nums = [9999999, 1, 1, 1]) == 2\n assert candidate(nums = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000]) == 9\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 16\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 12\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 12\n assert candidate(nums = [9999999, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == 9\n assert candidate(nums = [5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000]) == 10\n assert candidate(nums = [5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062.5, 19531.25, 9765.625]) == 3\n assert candidate(nums = [5000000, 3000000, 2000000, 4000000, 1000000]) == 5\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 20\n assert candidate(nums = [5000000, 4000000, 3000000, 2000000, 1000000, 500000, 250000, 125000, 62500, 31250]) == 5\n", "comparison": "exact"}, "public_tests": ["[5,19,8,1]", "[3,8,20]"], "hints": ["It is always optimal to halve the largest element.", "What data structure allows for an efficient query of the maximum element?", "Use a heap or priority queue to maintain the current elements."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().halveArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:57+00:00", "tests_total": 81, "tests_dropped": 4, "flags": [], "topic_tags": ["array", "greedy", "heap-priority-queue"]}, "language": "javascript", "interface": {"raw_signature": "var halveArray = function(nums) {", "container": null, "callable": "halveArray", "parameters": [{"name": "nums", "type": "number[]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2208, "task_id": "minimum-operations-to-halve-array-sum", "difficulty": "Medium", "problem_description": "You are given an array nums of positive integers. In one operation, you can choose any number from nums and reduce it to exactly half the number. (Note that you may choose this reduced number in future operations.)\n\nReturn the minimum number of operations to reduce the sum of nums by at least half.\n\nExample 1:\n\nInput: nums = [5,19,8,1]\nOutput: 3\nExplanation: The initial sum of nums is equal to 5 + 19 + 8 + 1 = 33.\nThe following is one of the ways to reduce the sum by at least half:\nPick the number 19 and reduce it to 9.5.\nPick the number 9.5 and reduce it to 4.75.\nPick the number 8 and reduce it to 4.\nThe final array is [5, 4.75, 4, 1] with a total sum of 5 + 4.75 + 4 + 1 = 14.75.\nThe sum of nums has been reduced by 33 - 14.75 = 18.25, which is at least half of the initial sum, 18.25 >= 33/2 = 16.5.\nOverall, 3 operations were used so we return 3.\nIt can be shown that we cannot reduce the sum by at least half in less than 3 operations.\n\nExample 2:\n\nInput: nums = [3,8,20]\nOutput: 3\nExplanation: The initial sum of nums is equal to 3 + 8 + 20 = 31.\nThe following is one of the ways to reduce the sum by at least half:\nPick the number 20 and reduce it to 10.\nPick the number 10 and reduce it to 5.\nPick the number 3 and reduce it to 1.5.\nThe final array is [1.5, 8, 5] with a total sum of 1.5 + 8 + 5 = 14.5.\nThe sum of nums has been reduced by 31 - 14.5 = 16.5, which is at least half of the initial sum, 16.5 >= 31/2 = 15.5.\nOverall, 3 operations were used so we return 3.\nIt can be shown that we cannot reduce the sum by at least half in less than 3 operations.\n\nConstraints:\n\n- 1 <= nums.length <= 10^5\n- 1 <= nums[i] <= 10^7\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [100, 100, 100, 100]) == 4\n assert candidate(nums = [3, 8, 20]) == 3\n assert candidate(nums = [10000000]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [5, 19, 8, 1]) == 3\n assert candidate(nums = [10, 20, 30, 40, 50]) == 5\n assert candidate(nums = [10, 10, 10, 10, 10]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 10\n assert candidate(nums = [10, 20, 30, 40]) == 4\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 3\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == 13\n assert candidate(nums = [9999999, 9999998, 9999997, 9999996, 9999995]) == 5\n assert candidate(nums = [5000000, 5000000, 5000000, 5000000, 5000000]) == 5\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953]) == 3\n assert candidate(nums = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250]) == 3\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584]) == 3\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 24\n assert candidate(nums = [1, 1000000, 100000, 10000, 1000]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 9\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 3\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 9\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 16\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 3\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 3\n assert candidate(nums = [5000000, 3000000, 2000000, 1000000, 500000, 300000, 200000, 100000]) == 4\n assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 30\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 15\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250]) == 3\n assert candidate(nums = [1234567, 2345678, 3456789, 4567890, 5678901, 6789012, 7890123, 8901234, 9012345]) == 8\n assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500]) == 16\n assert candidate(nums = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062, 19531]) == 3\n assert candidate(nums = [9999999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000]) == 4\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1]) == 10\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 18\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 3\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 9\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062, 19531, 9765, 4882, 2441, 1220, 610, 305, 152, 76, 38]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000]) == 2\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 20\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 12\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 25\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100000]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 14\n assert candidate(nums = [10000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 2\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) == 2\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 20\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 20\n assert candidate(nums = [9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991, 9999990]) == 10\n assert candidate(nums = [5000000, 5000000, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [9999999, 8888888, 7777777, 6666666, 5555555, 4444444, 3333333, 2222222, 1111111]) == 8\n assert candidate(nums = [9999999, 1, 1, 1]) == 2\n assert candidate(nums = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000]) == 9\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 16\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 12\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 12\n assert candidate(nums = [9999999, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == 9\n assert candidate(nums = [5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000]) == 10\n assert candidate(nums = [5000000, 3000000, 2000000, 4000000, 1000000]) == 5\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 20\n assert candidate(nums = [5000000, 4000000, 3000000, 2000000, 1000000, 500000, 250000, 125000, 62500, 31250]) == 5\n", "comparison": "exact"}, "public_tests": ["[5,19,8,1]", "[3,8,20]"], "hints": ["It is always optimal to halve the largest element.", "What data structure allows for an efficient query of the maximum element?", "Use a heap or priority queue to maintain the current elements."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().halveArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:57+00:00", "tests_total": 81, "tests_dropped": 7, "flags": [], "topic_tags": ["array", "greedy", "heap-priority-queue"]}, "language": "javascript", "interface": {"raw_signature": "var halveArray = function(nums) {", "container": null, "callable": "halveArray", "parameters": [{"name": "nums", "type": "number[]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2209, "task_id": "minimum-white-tiles-after-covering-with-carpets", "difficulty": "Hard", "problem_description": "You are given a 0-indexed binary string floor, which represents the colors of tiles on a floor:\n\n- floor[i] = '0' denotes that the i^th tile of the floor is colored black.\n- On the other hand, floor[i] = '1' denotes that the i^th tile of the floor is colored white.\n\nYou are also given numCarpets and carpetLen. You have numCarpets black carpets, each of length carpetLen tiles. Cover the tiles with the given carpets such that the number of white tiles still visible is minimum. Carpets may overlap one another.\n\nReturn the minimum number of white tiles still visible.\n\nExample 1:\n\nInput: floor = \"10110101\", numCarpets = 2, carpetLen = 2\nOutput: 2\nExplanation:\nThe figure above shows one way of covering the tiles with the carpets such that only 2 white tiles are visible.\nNo other way of covering the tiles with the carpets can leave less than 2 white tiles visible.\n\nExample 2:\n\nInput: floor = \"11111\", numCarpets = 2, carpetLen = 3\nOutput: 0\nExplanation:\nThe figure above shows one way of covering the tiles with the carpets such that no white tiles are visible.\nNote that the carpets are able to overlap one another.\n\nConstraints:\n\n- 1 <= carpetLen <= floor.length <= 1000\n- floor[i] is either '0' or '1'.\n- 1 <= numCarpets <= 1000\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(floor = \"111100001111\",numCarpets = 4,carpetLen = 4) == 0\n assert candidate(floor = \"110011\",numCarpets = 3,carpetLen = 2) == 0\n assert candidate(floor = \"11111\",numCarpets = 2,carpetLen = 3) == 0\n assert candidate(floor = \"1010101010\",numCarpets = 5,carpetLen = 1) == 0\n assert candidate(floor = \"11001100\",numCarpets = 3,carpetLen = 2) == 0\n assert candidate(floor = \"11010110\",numCarpets = 3,carpetLen = 1) == 2\n assert candidate(floor = \"10110101\",numCarpets = 2,carpetLen = 2) == 2\n assert candidate(floor = \"1110111\",numCarpets = 1,carpetLen = 4) == 3\n assert candidate(floor = \"111000111\",numCarpets = 2,carpetLen = 4) == 0\n assert candidate(floor = \"00000\",numCarpets = 1,carpetLen = 1) == 0\n assert candidate(floor = \"00000\",numCarpets = 1,carpetLen = 2) == 0\n assert candidate(floor = \"1111001111001111001111001111001111001111001111001111001111\",numCarpets = 12,carpetLen = 5) == 0\n assert candidate(floor = \"110011001100110011001100110011001100110011001100\",numCarpets = 5,carpetLen = 3) == 14\n assert candidate(floor = \"10101010101010101010101010101010101010101010\",numCarpets = 20,carpetLen = 5) == 0\n assert candidate(floor = \"110011001100110011001100110011001100110011001100\",numCarpets = 15,carpetLen = 4) == 0\n assert candidate(floor = \"010101010101010101010101010101010101010101010101\",numCarpets = 10,carpetLen = 5) == 0\n assert candidate(floor = \"111101010101010101010101010101010101010101\",numCarpets = 10,carpetLen = 7) == 0\n assert candidate(floor = \"110001001001001001001001001001001001001001001001\",numCarpets = 20,carpetLen = 4) == 0\n assert candidate(floor = \"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\",numCarpets = 20,carpetLen = 5) == 0\n assert candidate(floor = \"1111000011110000111100001111\",numCarpets = 6,carpetLen = 4) == 0\n assert candidate(floor = \"0000000000000000000000000000\",numCarpets = 10,carpetLen = 10) == 0\n assert candidate(floor = \"11111111111111111111111111111111111111\",numCarpets = 1000,carpetLen = 1) == 0\n assert candidate(floor = \"11111000001111111100\",numCarpets = 4,carpetLen = 4) == 0\n assert candidate(floor = \"11110111101111011110111101\",numCarpets = 10,carpetLen = 2) == 1\n assert candidate(floor = \"010101010101010101010101010101010101010101010101\",numCarpets = 18,carpetLen = 7) == 0\n assert candidate(floor = \"101010101010101010101010101010101010101010101010\",numCarpets = 25,carpetLen = 2) == 0\n assert candidate(floor = \"10000000000000000000000000\",numCarpets = 1,carpetLen = 10) == 0\n assert candidate(floor = \"11100011111000111000\",numCarpets = 5,carpetLen = 4) == 0\n assert candidate(floor = \"111111111111111111111111111111111111111111111111\",numCarpets = 10,carpetLen = 5) == 0\n assert candidate(floor = \"10101010101010101010101010101010101010101010101010\",numCarpets = 15,carpetLen = 4) == 0\n assert candidate(floor = \"10001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000\",numCarpets = 25,carpetLen = 8) == 0\n assert candidate(floor = \"00001111000011110000111100001111\",numCarpets = 12,carpetLen = 4) == 0\n assert candidate(floor = \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\",numCarpets = 50,carpetLen = 10) == 0\n assert candidate(floor = \"0000000000000000000000000000000000000000\",numCarpets = 20,carpetLen = 5) == 0\n assert candidate(floor = \"1010101010101010101010101010101010101010101010101010\",numCarpets = 10,carpetLen = 2) == 16\n assert candidate(floor = \"10010010010010010010010010010010010010\",numCarpets = 10,carpetLen = 3) == 3\n assert candidate(floor = \"01010101010101010101\",numCarpets = 5,carpetLen = 4) == 0\n assert candidate(floor = \"0001111111000111111000111111\",numCarpets = 6,carpetLen = 5) == 0\n assert candidate(floor = \"01010101010101010101010101010101010101\",numCarpets = 8,carpetLen = 2) == 11\n assert candidate(floor = \"11111000011111000011111000011111\",numCarpets = 4,carpetLen = 5) == 0\n assert candidate(floor = \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\",numCarpets = 100,carpetLen = 10) == 0\n assert candidate(floor = \"0101010101010101010101010101\",numCarpets = 10,carpetLen = 3) == 0\n assert candidate(floor = \"11100011100011100011\",numCarpets = 6,carpetLen = 3) == 0\n assert candidate(floor = \"11111111111111111111\",numCarpets = 3,carpetLen = 5) == 5\n assert candidate(floor = \"111111000011111100001111110000111111\",numCarpets = 8,carpetLen = 5) == 0\n assert candidate(floor = \"1111111111111111111111111111111111111111\",numCarpets = 16,carpetLen = 10) == 0\n assert candidate(floor = \"1010101010101010101010101010101010101010101010101010101010101010\",numCarpets = 20,carpetLen = 6) == 0\n assert candidate(floor = \"11001100110011001100110011001100\",numCarpets = 8,carpetLen = 2) == 0\n assert candidate(floor = \"00100100100100100100100100\",numCarpets = 10,carpetLen = 3) == 0\n assert candidate(floor = \"11111111111111111111111111\",numCarpets = 15,carpetLen = 2) == 0\n assert candidate(floor = \"1111011011111100001101110111\",numCarpets = 5,carpetLen = 6) == 0\n assert candidate(floor = \"111111111111111111111111111111111111111111111111\",numCarpets = 50,carpetLen = 1) == 0\n assert candidate(floor = \"110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100\",numCarpets = 15,carpetLen = 4) == 24\n assert candidate(floor = \"11101110111011101110111011\",numCarpets = 7,carpetLen = 4) == 0\n assert candidate(floor = \"101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\",numCarpets = 15,carpetLen = 4) == 18\n assert candidate(floor = \"100110011001100110011001100110011001\",numCarpets = 8,carpetLen = 4) == 2\n assert candidate(floor = \"10101010101010101010101010101010\",numCarpets = 7,carpetLen = 4) == 2\n assert candidate(floor = \"1111000011110000111100001111000011110000111100001111000011110000111100001111000011110000\",numCarpets = 10,carpetLen = 7) == 4\n assert candidate(floor = \"111100001111000011110000111100001111000011110000\",numCarpets = 5,carpetLen = 4) == 4\n assert candidate(floor = \"11111111111111111111111111\",numCarpets = 10,carpetLen = 6) == 0\n assert candidate(floor = \"10001000100010001000100010001000\",numCarpets = 9,carpetLen = 3) == 0\n assert candidate(floor = \"111000111000111000111000111000111000\",numCarpets = 10,carpetLen = 2) == 2\n assert candidate(floor = \"111111000000111111000000111111000000111111000000111111\",numCarpets = 15,carpetLen = 7) == 0\n assert candidate(floor = \"111111111111111111111111111111111111\",numCarpets = 10,carpetLen = 7) == 0\n assert candidate(floor = \"11111111111111111111111111111111\",numCarpets = 5,carpetLen = 5) == 7\n assert candidate(floor = \"01010101010101010101010101\",numCarpets = 10,carpetLen = 5) == 0\n assert candidate(floor = \"1010101010101010101010101010101010101010101010101010101010101010\",numCarpets = 30,carpetLen = 4) == 0\n assert candidate(floor = \"1010101010101010101010101010\",numCarpets = 10,carpetLen = 5) == 0\n assert candidate(floor = \"01010101010101010101\",numCarpets = 3,carpetLen = 2) == 7\n assert candidate(floor = \"11111111111111111111\",numCarpets = 5,carpetLen = 5) == 0\n assert candidate(floor = \"1111000011110000111100001111000011110000111100001111000011110000111100001111000011110000\",numCarpets = 30,carpetLen = 5) == 0\n assert candidate(floor = \"11110000111100001111\",numCarpets = 4,carpetLen = 5) == 0\n assert candidate(floor = \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\",numCarpets = 50,carpetLen = 12) == 0\n assert candidate(floor = \"10101010101010101010101010\",numCarpets = 15,carpetLen = 2) == 0\n assert candidate(floor = \"11010101010101010101\",numCarpets = 5,carpetLen = 3) == 1\n assert candidate(floor = \"11101110111011101110111011101110\",numCarpets = 10,carpetLen = 2) == 6\n assert candidate(floor = \"000000000000000000000000000000000000000000000000\",numCarpets = 10,carpetLen = 15) == 0\n assert candidate(floor = \"11111111111111111111111111111111\",numCarpets = 15,carpetLen = 5) == 0\n assert candidate(floor = \"111111111111111111111111111111111111111111111111\",numCarpets = 25,carpetLen = 10) == 0\n assert candidate(floor = \"11111111000000001111111100000000\",numCarpets = 3,carpetLen = 8) == 0\n assert candidate(floor = \"110110110110110110110110110110110110110110110110\",numCarpets = 12,carpetLen = 6) == 0\n assert candidate(floor = \"1111000011110000111100001111000011110000111100001111\",numCarpets = 10,carpetLen = 8) == 0\n assert candidate(floor = \"01010101010101010101010101010101010101010101\",numCarpets = 4,carpetLen = 7) == 6\n assert candidate(floor = \"1111111111111111111111111111\",numCarpets = 15,carpetLen = 4) == 0\n assert candidate(floor = \"11111111111111111111\",numCarpets = 6,carpetLen = 5) == 0\n assert candidate(floor = \"111111111100000000000000111111111111111111111111\",numCarpets = 5,carpetLen = 10) == 0\n assert candidate(floor = \"100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100\",numCarpets = 20,carpetLen = 6) == 0\n assert candidate(floor = \"1111100000111110000011111\",numCarpets = 3,carpetLen = 6) == 0\n assert candidate(floor = \"01010101010101010101010101010101\",numCarpets = 10,carpetLen = 3) == 0\n assert candidate(floor = \"11110111101111011110\",numCarpets = 5,carpetLen = 3) == 2\n assert candidate(floor = \"00101010101010101010\",numCarpets = 5,carpetLen = 3) == 0\n assert candidate(floor = \"11111111111111111111\",numCarpets = 10,carpetLen = 2) == 0\n assert candidate(floor = \"111000111000111000111000111000111\",numCarpets = 8,carpetLen = 4) == 0\n assert candidate(floor = \"10101010101010101010\",numCarpets = 5,carpetLen = 3) == 0\n assert candidate(floor = \"11110000111100001111000011110000\",numCarpets = 6,carpetLen = 4) == 0\n assert candidate(floor = \"10101010101010101010101010101010101010101010101010101010101010101010101010101010\",numCarpets = 20,carpetLen = 5) == 0\n assert candidate(floor = \"111000111000111000111\",numCarpets = 4,carpetLen = 3) == 0\n assert candidate(floor = \"10101010101010101010\",numCarpets = 3,carpetLen = 4) == 4\n assert candidate(floor = \"000000000000000000000000000000000000000000000000\",numCarpets = 10,carpetLen = 3) == 0\n assert candidate(floor = \"1001001001001001001001001\",numCarpets = 7,carpetLen = 4) == 0\n assert candidate(floor = \"01010101010101010101010101010101010101010101010101010101010\",numCarpets = 25,carpetLen = 3) == 0\n assert candidate(floor = \"11111111111111111111\",numCarpets = 5,carpetLen = 3) == 5\n assert candidate(floor = \"101010101010101010101010101010101010\",numCarpets = 15,carpetLen = 6) == 0\n assert candidate(floor = \"111101110111011101110111011101110111\",numCarpets = 5,carpetLen = 4) == 12\n assert candidate(floor = \"1010101010101010101010101010\",numCarpets = 8,carpetLen = 3) == 0\n assert candidate(floor = \"000101001010100110010010001000101010010101010101\",numCarpets = 15,carpetLen = 3) == 0\n assert candidate(floor = \"11001100110011001100\",numCarpets = 8,carpetLen = 3) == 0\n assert candidate(floor = \"1110111011101110111011101110111011101110111011101110111011101110\",numCarpets = 8,carpetLen = 3) == 24\n", "comparison": "exact"}, "public_tests": ["\"10110101\"\n2\n2", "\"11111\"\n2\n3"], "hints": ["Can you think of a DP solution?", "Let DP[i][j] denote the minimum number of white tiles still visible from indices i to floor.length-1 after covering with at most j carpets.", "The transition will be whether to put down the carpet at position i (if possible), or not."], "metadata": {"canonical_parameter_names": ["floor", "numCarpets", "carpetLen"], "leetcode_dataset_entry_point": "Solution().minimumWhiteTiles", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:44:59+00:00", "tests_total": 110, "tests_dropped": 2, "flags": ["figure_reference", "has_images"], "topic_tags": ["string", "dynamic-programming", "prefix-sum"]}, "language": "javascript", "interface": {"raw_signature": "var minimumWhiteTiles = function(floor, numCarpets, carpetLen) {", "container": null, "callable": "minimumWhiteTiles", "parameters": [{"name": "floor", "type": "string"}, {"name": "numCarpets", "type": "number"}, {"name": "carpetLen", "type": "number"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2210, "task_id": "count-hills-and-valleys-in-an-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums. An index i is part of a hill in nums if the closest non-equal neighbors of i are smaller than nums[i]. Similarly, an index i is part of a valley in nums if the closest non-equal neighbors of i are larger than nums[i]. Adjacent indices i and j are part of the same hill or valley if nums[i] == nums[j].\n\nNote that for an index to be part of a hill or valley, it must have a non-equal neighbor on both the left and right of the index.\n\nReturn the number of hills and valleys in nums.\n\nExample 1:\n\nInput: nums = [2,4,1,1,6,5]\nOutput: 3\nExplanation:\nAt index 0: There is no non-equal neighbor of 2 on the left, so index 0 is neither a hill nor a valley.\nAt index 1: The closest non-equal neighbors of 4 are 2 and 1. Since 4 > 2 and 4 > 1, index 1 is a hill.\nAt index 2: The closest non-equal neighbors of 1 are 4 and 6. Since 1 < 4 and 1 < 6, index 2 is a valley.\nAt index 3: The closest non-equal neighbors of 1 are 4 and 6. Since 1 < 4 and 1 < 6, index 3 is a valley, but note that it is part of the same valley as index 2.\nAt index 4: The closest non-equal neighbors of 6 are 1 and 5. Since 6 > 1 and 6 > 5, index 4 is a hill.\nAt index 5: There is no non-equal neighbor of 5 on the right, so index 5 is neither a hill nor a valley.\nThere are 3 hills and valleys so we return 3.\n\nExample 2:\n\nInput: nums = [6,6,5,5,4,1]\nOutput: 0\nExplanation:\nAt index 0: There is no non-equal neighbor of 6 on the left, so index 0 is neither a hill nor a valley.\nAt index 1: There is no non-equal neighbor of 6 on the left, so index 1 is neither a hill nor a valley.\nAt index 2: The closest non-equal neighbors of 5 are 6 and 4. Since 5 < 6 and 5 > 4, index 2 is neither a hill nor a valley.\nAt index 3: The closest non-equal neighbors of 5 are 6 and 4. Since 5 < 6 and 5 > 4, index 3 is neither a hill nor a valley.\nAt index 4: The closest non-equal neighbors of 4 are 5 and 1. Since 4 < 5 and 4 > 1, index 4 is neither a hill nor a valley.\nAt index 5: There is no non-equal neighbor of 1 on the right, so index 5 is neither a hill nor a valley.\nThere are 0 hills and valleys so we return 0.\n\nConstraints:\n\n- 3 <= nums.length <= 100\n- 1 <= nums[i] <= 100\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 0\n assert candidate(nums = [100, 99, 100, 98, 99, 100]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100, 90, 80, 70, 60, 50]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [5, 4, 4, 3, 3, 2, 2, 1]) == 0\n assert candidate(nums = [3, 3, 3, 2, 2, 1, 1]) == 0\n assert candidate(nums = [1, 3, 2, 3, 1]) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5]) == 4\n assert candidate(nums = [3, 1, 2, 1, 3, 2, 1]) == 4\n assert candidate(nums = [2, 4, 1, 1, 6, 5]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 2, 1, 2, 2, 1]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 1, 2, 2, 1, 1]) == 1\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 1]) == 3\n assert candidate(nums = [6, 6, 5, 5, 4, 1]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 3, 3, 3, 2, 2, 2, 1]) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 2, 2, 2, 3]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3]) == 2\n assert candidate(nums = [1, 3, 1, 2, 1, 3, 1]) == 5\n assert candidate(nums = [1, 2, 3, 2, 1]) == 1\n assert candidate(nums = [10, 9, 8, 7, 8, 9, 10]) == 1\n assert candidate(nums = [1, 1, 2, 2, 1, 1, 2, 2]) == 2\n assert candidate(nums = [50, 50, 49, 51, 49, 51, 50]) == 4\n assert candidate(nums = [9, 8, 9, 8, 9, 8, 9]) == 5\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3]) == 3\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 96, 97, 98, 99, 100]) == 1\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2]) == 9\n assert candidate(nums = [3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3]) == 11\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 4, 3, 2, 1]) == 5\n assert candidate(nums = [3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1]) == 10\n assert candidate(nums = [50, 50, 50, 50, 51, 50, 50, 50, 50, 51, 50, 50, 50, 50]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 4, 3, 2, 1, 1, 1]) == 1\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2]) == 5\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9]) == 12\n assert candidate(nums = [10, 9, 8, 7, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 6, 7, 8, 9]) == 3\n assert candidate(nums = [1, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == 17\n assert candidate(nums = [100, 90, 100, 90, 100, 90, 100, 80, 90, 80]) == 8\n assert candidate(nums = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4]) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 2, 2, 1, 1]) == 1\n assert candidate(nums = [3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 3, 3, 2, 2, 1, 1, 2, 2]) == 3\n assert candidate(nums = [1, 3, 2, 3, 1, 3, 2, 1, 2, 3, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 2, 3, 1, 2, 1]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums = [2, 2, 2, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 28\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5]) == 3\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 8\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 2, 1, 3, 2, 3, 1]) == 9\n assert candidate(nums = [1, 2, 2, 1, 2, 3, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 7\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 7\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 1, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [10, 20, 10, 30, 10, 20, 10, 30, 10, 20, 10]) == 9\n assert candidate(nums = [50, 51, 52, 51, 50, 51, 52, 51, 50, 51, 52, 51]) == 5\n assert candidate(nums = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4]) == 8\n assert candidate(nums = [1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1]) == 9\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 6, 5, 7, 4, 8, 3, 9, 2, 10]) == 18\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2]) == 4\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 9\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9]) == 12\n assert candidate(nums = [1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2]) == 8\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(nums = [30, 20, 10, 20, 30, 20, 10, 20, 30, 20, 10]) == 4\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 13\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 8\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 5\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 0\n assert candidate(nums = [2, 2, 2, 3, 3, 2, 2, 2, 1, 1, 2, 2, 2]) == 2\n assert candidate(nums = [3, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 8\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 1, 2, 1, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 8, 7, 8, 9]) == 13\n assert candidate(nums = [100, 99, 98, 97, 98, 99, 100, 99, 98, 97, 96, 97, 98, 99, 100, 99]) == 4\n assert candidate(nums = [1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1]) == 5\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2]) == 8\n assert candidate(nums = [1, 1, 1, 2, 3, 4, 5, 5, 5, 4, 3, 2, 1, 1, 1]) == 1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 96, 97, 98, 99, 100]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1]) == 3\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 2, 1]) == 5\n assert candidate(nums = [8, 7, 6, 7, 8, 7, 6, 7, 8, 7, 6, 7, 8, 7, 6, 7, 8, 7, 6, 5]) == 8\n assert candidate(nums = [7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 19\n assert candidate(nums = [2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 14\n assert candidate(nums = [10, 9, 8, 7, 6, 7, 8, 9, 10, 9]) == 2\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2]) == 3\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 9\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 2, 3, 2, 1, 3, 2, 1, 2, 3, 2, 1, 3, 2, 1, 2, 3]) == 16\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 6\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(nums = [10, 9, 8, 7, 8, 9, 10, 9, 8, 7, 6]) == 2\n assert candidate(nums = [1, 1, 2, 3, 4, 3, 2, 1, 1, 2, 3, 4, 3, 2, 1, 1, 2, 3, 4]) == 4\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 3, 4, 3, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2]) == 7\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 5, 6, 7, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 7, 8]) == 10\n assert candidate(nums = [50, 49, 50, 49, 50, 49, 50, 49, 50, 49, 50, 49, 50, 49, 50, 49, 50, 49, 50]) == 17\n assert candidate(nums = [2, 2, 2, 1, 2, 2, 3, 2, 2, 2, 1, 2, 2, 3, 2, 2, 2, 1, 2, 2]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9]) == 2\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 1\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5]) == 11\n assert candidate(nums = [1, 3, 2, 1, 2, 1, 2, 1, 2, 1, 3, 2, 1, 2, 1]) == 11\n assert candidate(nums = [1, 2, 2, 2, 3, 2, 2, 2, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 7\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 8\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 3, 4]) == 8\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 11\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 0\n assert candidate(nums = [3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 14\n assert candidate(nums = [20, 21, 20, 22, 21, 23, 22, 24, 23, 25, 24, 23, 22, 21, 20, 19, 20, 21, 22, 21]) == 11\n assert candidate(nums = [1, 3, 3, 3, 2, 2, 2, 1, 3, 3, 3, 2, 2, 2]) == 3\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 2, 1]) == 5\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 3\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 3\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 13\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 2, 2, 1, 1, 2, 2]) == 2\n assert candidate(nums = [1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1]) == 9\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 18\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 18\n assert candidate(nums = [10, 9, 8, 7, 8, 9, 10, 9, 8, 7, 6, 7, 8, 9, 10]) == 3\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6]) == 11\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 2, 2, 2]) == 1\n assert candidate(nums = [3, 3, 3, 2, 2, 1, 1, 1, 2, 2, 3, 3, 3, 2, 2, 1, 1, 1]) == 2\n assert candidate(nums = [1, 2, 2, 1, 2, 3, 3, 2, 1, 2, 3, 4, 4, 3, 2, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 8\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [9, 8, 7, 8, 7, 8, 9, 10, 9, 10, 9, 8, 7, 8, 7, 6, 5, 4, 5, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8]) == 13\n assert candidate(nums = [3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 3, 3, 2, 2, 1]) == 1\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10]) == 7\n", "comparison": "exact"}, "public_tests": ["[2,4,1,1,6,5]", "[6,6,5,5,4,1]"], "hints": ["For each index, could you find the closest non-equal neighbors?", "Ensure that adjacent indices that are part of the same hill or valley are not double-counted."], "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countHillValley", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:01+00:00", "tests_total": 154, "tests_dropped": 0, "flags": [], "topic_tags": ["array"]}, "language": "javascript", "interface": {"raw_signature": "var countHillValley = function(nums) {", "container": null, "callable": "countHillValley", "parameters": [{"name": "nums", "type": "number[]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2211, "task_id": "count-collisions-on-a-road", "difficulty": "Medium", "problem_description": "There are n cars on an infinitely long road. The cars are numbered from 0 to n - 1 from left to right and each car is present at a unique point.\n\nYou are given a 0-indexed string directions of length n. directions[i] can be either 'L', 'R', or 'S' denoting whether the i^th car is moving towards the left, towards the right, or staying at its current point respectively. Each moving car has the same speed.\n\nThe number of collisions can be calculated as follows:\n\n- When two cars moving in opposite directions collide with each other, the number of collisions increases by 2.\n- When a moving car collides with a stationary car, the number of collisions increases by 1.\n\nAfter a collision, the cars involved can no longer move and will stay at the point where they collided. Other than that, cars cannot change their state or direction of motion.\n\nReturn the total number of collisions that will happen on the road.\n\nExample 1:\n\nInput: directions = \"RLRSLL\"\nOutput: 5\nExplanation:\nThe collisions that will happen on the road are:\n- Cars 0 and 1 will collide with each other. Since they are moving in opposite directions, the number of collisions becomes 0 + 2 = 2.\n- Cars 2 and 3 will collide with each other. Since car 3 is stationary, the number of collisions becomes 2 + 1 = 3.\n- Cars 3 and 4 will collide with each other. Since car 3 is stationary, the number of collisions becomes 3 + 1 = 4.\n- Cars 4 and 5 will collide with each other. After car 4 collides with car 3, it will stay at the point of collision and get hit by car 5. The number of collisions becomes 4 + 1 = 5.\nThus, the total number of collisions that will happen on the road is 5.\n\nExample 2:\n\nInput: directions = \"LLRR\"\nOutput: 0\nExplanation:\nNo cars will collide with each other. Thus, the total number of collisions that will happen on the road is 0.\n\nConstraints:\n\n- 1 <= directions.length <= 10^5\n- directions[i] is either 'L', 'R', or 'S'.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(directions = \"SSRLSL\") == 3\n assert candidate(directions = \"LRLRLR\") == 4\n assert candidate(directions = \"RRRR\") == 0\n assert candidate(directions = \"LRRSLRLR\") == 5\n assert candidate(directions = \"LSRL\") == 2\n assert candidate(directions = \"SSSS\") == 0\n assert candidate(directions = \"RLSLRL\") == 5\n assert candidate(directions = \"RSLSLSLS\") == 4\n assert candidate(directions = \"SSSRRSLL\") == 4\n assert candidate(directions = \"LRSLSR\") == 2\n assert candidate(directions = \"RLSL\") == 3\n assert candidate(directions = \"RLLLLLL\") == 7\n assert candidate(directions = \"RRRRRRS\") == 6\n assert candidate(directions = \"LLRR\") == 0\n assert candidate(directions = \"RRLR\") == 3\n assert candidate(directions = \"SSLSLS\") == 2\n assert candidate(directions = \"RLRRLL\") == 6\n assert candidate(directions = \"RRRSSSLL\") == 5\n assert candidate(directions = \"SSSSS\") == 0\n assert candidate(directions = \"LLLLL\") == 0\n assert candidate(directions = \"RLRSLL\") == 5\n assert candidate(directions = \"LSLR\") == 1\n assert candidate(directions = \"LLLL\") == 0\n assert candidate(directions = \"RSLRS\") == 3\n assert candidate(directions = \"RSLRLRLS\") == 6\n assert candidate(directions = \"RRSLRR\") == 3\n assert candidate(directions = \"LRLR\") == 2\n assert candidate(directions = \"RRRSSSLLLRRR\") == 6\n assert candidate(directions = \"LSRLSL\") == 3\n assert candidate(directions = \"LRLL\") == 3\n assert candidate(directions = \"SSRLSS\") == 2\n assert candidate(directions = \"RRRRR\") == 0\n assert candidate(directions = \"RSLR\") == 2\n assert candidate(directions = \"SSS\") == 0\n assert candidate(directions = \"LRRLRRLL\") == 7\n assert candidate(directions = \"RSLRSL\") == 4\n assert candidate(directions = \"LSSRLL\") == 3\n assert candidate(directions = \"RSLRLR\") == 4\n assert candidate(directions = \"SSRSLLS\") == 3\n assert candidate(directions = \"RRRRRSSSSSLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLSSSSSSSSSSS\") == 43\n assert candidate(directions = \"LRLRLRLRLRLR\") == 10\n assert candidate(directions = \"RRLRLRLRLRLRLRLRLRLR\") == 19\n assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 0\n assert candidate(directions = \"SSRSLRRRLLSLSSS\") == 8\n assert candidate(directions = \"RRRRRSSLLLLLRRRR\") == 10\n assert candidate(directions = \"RLLLLRRRRLLLLRRRRRLLLLRRRR\") == 22\n assert candidate(directions = \"RSSSSRRRRRRRRRRSSSLL\") == 13\n assert candidate(directions = \"RRRRRRRRRRSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 10\n assert candidate(directions = \"LRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"RLRLRLRLRLRLRLRL\") == 16\n assert candidate(directions = \"RRRSSLLLLRRRSSLLLL\") == 14\n assert candidate(directions = \"RRRLRSSRRRLRRRRRSLRRRRRR\") == 15\n assert candidate(directions = \"RLRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 2\n assert candidate(directions = \"RSLRRSLRRSLR\") == 8\n assert candidate(directions = \"LLLSRSSRRRLRRRRRSLRRRRRR\") == 11\n assert candidate(directions = \"RLRSLLRSLLRSLLRSLLRS\") == 15\n assert candidate(directions = \"LLLLLLLLLLSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n assert candidate(directions = \"RSLRSLRSLRSLRSLRSLRSLRSLRL\") == 18\n assert candidate(directions = \"LLLLSSSSRRRRRRRRRLLLLL\") == 14\n assert candidate(directions = \"RRRRSSSSLLLLRRRRRRSSSSLLLLRRRRRRSSSSLLLL\") == 28\n assert candidate(directions = \"RRRRRRRRRRRR\") == 0\n assert candidate(directions = \"SLRLRLRLRLRSLSLSL\") == 13\n assert candidate(directions = \"LLLLSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSRRRRRR\") == 0\n assert candidate(directions = \"RSSSSRRRLLLLRRRSL\") == 12\n assert candidate(directions = \"RRRRRRRRRRSSSSSSSSSLLLLLLLL\") == 18\n assert candidate(directions = \"LRRRRRLLLLLS\") == 10\n assert candidate(directions = \"SLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 44\n assert candidate(directions = \"LLLLLLLLLLLLLLLL\") == 0\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"RRRSLSLSSSLLLLRRRS\") == 12\n assert candidate(directions = \"LLLLRRRRRRRR\") == 0\n assert candidate(directions = \"RLRSRLRSRLRSRLRS\") == 12\n assert candidate(directions = \"SSSSSSSSSSSSSSRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLLLLLLLLLLLLLLLLLLLLSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 52\n assert candidate(directions = \"RLRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 2\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"SSSSSSSSSSSS\") == 0\n assert candidate(directions = \"RSLRSLSRLRSLSR\") == 8\n assert candidate(directions = \"RRRSLSLRSLRRRRLLL\") == 14\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"SSSSSRRRRRSSSSS\") == 5\n assert candidate(directions = \"RRRRSSSLLLLLRRRR\") == 9\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLRRRR\") == 44\n assert candidate(directions = \"SSRRRRLLLLSSRRRRLLLLSS\") == 16\n assert candidate(directions = \"RSLRSLSRLSRLSRLRSLSR\") == 12\n assert candidate(directions = \"RRRRRRRRLLLLLLLL\") == 16\n assert candidate(directions = \"SLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 46\n assert candidate(directions = \"RRRLLRRRLLLLLSS\") == 13\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLRRRRRRR\") == 43\n assert candidate(directions = \"LLLLLRRRRRLLLLLRRRRRLLLLLRRRRRLLLLLRRRRR\") == 30\n assert candidate(directions = \"LLLLRRRRRRSSSSSLLLL\") == 10\n assert candidate(directions = \"RLRLRLRLRLRL\") == 12\n assert candidate(directions = \"RLRSLRSLRSLRSLRS\") == 11\n assert candidate(directions = \"RRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"SLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 48\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLRR\") == 44\n assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 0\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLRRRRRR\") == 44\n assert candidate(directions = \"SSSSSSRRRRRSSSSSSSSS\") == 5\n assert candidate(directions = \"LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR\") == 38\n assert candidate(directions = \"SSSLRRRLLSSL\") == 7\n assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n assert candidate(directions = \"RRRLRLRLRLRLRLRLRLRLRLRLRLRRRRRRRRRRRR\") == 26\n assert candidate(directions = \"SSSSRRRRLLLLRRRRLLLL\") == 16\n assert candidate(directions = \"RRRRRLSLLSLLLL\") == 12\n assert candidate(directions = \"SSSSSSSSSSSSSSSS\") == 0\n assert candidate(directions = \"RRRRRSSSSLLLLLLLL\") == 13\n assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 0\n assert candidate(directions = \"RLRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 2\n assert candidate(directions = \"SSRRRRRSSSSLLLSSSL\") == 9\n assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSS\") == 0\n assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 0\n assert candidate(directions = \"RLRRLLRLRRLLRLRR\") == 14\n assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLLLLLLSSSS\") == 0\n assert candidate(directions = \"RRRRSSSSSSRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRL\") == 38\n assert candidate(directions = \"LSRSSRSLLRSRLS\") == 7\n assert candidate(directions = \"LLLLLLRRRRRRLLLLRRRRRR\") == 10\n assert candidate(directions = \"LLLLSSSSRRRRSSSSLLLL\") == 8\n assert candidate(directions = \"SSSSSSSSSSSRRRRRRSSSSSSLLLLLLLLSSSSSSSSSSS\") == 14\n assert candidate(directions = \"RRRSSLRLRLRSLL\") == 11\n assert candidate(directions = \"RSLSLRLSLSLRLSLR\") == 10\n assert candidate(directions = \"SSSSSRRRRRSSSSSLLLLL\") == 10\n assert candidate(directions = \"SSSSRRRRSSSSSSSSSSSSSSSSSSS\") == 4\n assert candidate(directions = \"SSSSRRRRRRLLLLSSSSSLLLL\") == 14\n assert candidate(directions = \"SSLRRRSSLLSL\") == 7\n assert candidate(directions = \"RRSSSLRSLSSSRRSSSLRSL\") == 10\n assert candidate(directions = \"LSLSLSLSLSLSLSLSLRRRRRR\") == 8\n assert candidate(directions = \"LLLLSSRRRRSSSSRRRR\") == 4\n assert candidate(directions = \"RSLSRSLSRSLSRS\") == 7\n assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n assert candidate(directions = \"RSLRSSLSRSSL\") == 6\n assert candidate(directions = \"LRLRLRLRLRLRLRLRLRLR\") == 18\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLRRRRRR\") == 43\n assert candidate(directions = \"RRRRRSSSLLLLLLLLRRRR\") == 13\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"LLLLRRRRSSSSLLRRRR\") == 6\n assert candidate(directions = \"LRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"LLLSRLRLRLRLRLL\") == 11\n assert candidate(directions = \"RRRRSSSSLLLL\") == 8\n assert candidate(directions = \"RLRLRLRLRLRLRLRLRLRL\") == 20\n assert candidate(directions = \"LLLLRRRRSSSSLLLL\") == 8\n assert candidate(directions = \"LRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRLL\") == 46\n assert candidate(directions = \"RRRRRRRRRSSSSSSSLLLLLLLLSSSSSSSSSSSSSSSSSS\") == 17\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRLLSSSSSSSSSSSSSSSSSL\") == 22\n assert candidate(directions = \"RLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRL\") == 40\n assert candidate(directions = \"LRRRSLRRRLSLSLLSLRR\") == 12\n assert candidate(directions = \"LRRRLRRLLRLLRLRRRLLR\") == 18\n assert candidate(directions = \"RRRRLLLLRRRRLLLLRRRRLLLLRRRRLLLLRRRRLLLL\") == 40\n assert candidate(directions = \"SRLRSRLRSRLRSRLRSRLRSRLRSRLRSRLRSRLRSR\") == 27\n assert candidate(directions = \"RRRRRSSLLLLLLLLLL\") == 15\n assert candidate(directions = \"SSSSRRRRLLLLSSSS\") == 8\n assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n assert candidate(directions = \"SSSSRRRRLLLLSSSSRRRR\") == 8\n assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n assert candidate(directions = \"SRRRRRLRRRRLLSRRRRLLL\") == 19\n assert candidate(directions = \"RRRLLLLLSSSSRRRLLLLL\") == 16\n assert candidate(directions = \"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\") == 0\n assert candidate(directions = \"RLLLLLRRRRRR\") == 6\n assert candidate(directions = \"RSLRRSLSLSLSLSLSL\") == 10\n assert candidate(directions = \"RLRSLRSLRSLRSLRSLRSLRSLRSLRSLRSLR\") == 22\n assert candidate(directions = \"RRRRRRRRRRLLLLLLLLLL\") == 20\n assert candidate(directions = \"RRRRSSSLLLLLLLRRRRRR\") == 11\n assert candidate(directions = \"SSSSRRRRLLLLLRRRRLLLLLSSSSRRRRLLLLLRRRRLLLLL\") == 36\n assert candidate(directions = \"LLLLLLLLLLSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSRRRR\") == 0\n assert candidate(directions = \"RRRRRRRRRRRRRRSSSLSSSSSSSSSSSSSSSSSSSSSSSL\") == 16\n assert candidate(directions = \"RRRRRRSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSLLLLLL\") == 12\n assert candidate(directions = \"RRRRLLLLSSSSRRRLLL\") == 14\n assert candidate(directions = \"LLLLLLLLLLLLLLLLLLLL\") == 0\n assert candidate(directions = \"RLRRRLRLRLRLRLRLRLRLRLRLRLRR\") == 26\n assert candidate(directions = \"RRRRRSSSSSSLLLLSSSSSS\") == 9\n assert candidate(directions = \"SSRRRRRLLLLLSS\") == 10\n assert candidate(directions = \"RRRRRRRRRRRRRLLLLLLLLLLLL\") == 25\n assert candidate(directions = \"RRRRRRRRRRSSSSSSSSSSSSSSSSSSSSSSSSSSSSSLLLL\") == 14\n assert candidate(directions = \"RSLSLRSLRRSLRSLRL\") == 12\n assert candidate(directions = \"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\") == 0\n assert candidate(directions = \"RSSSSSSRRRRRRRLLLLLLLLLLLLLRRRRRR\") == 21\n assert candidate(directions = \"RLRSLRLRSLRL\") == 10\n", "comparison": "exact"}, "public_tests": ["\"RLRSLL\"", "\"LLRR\""], "hints": ["In what circumstances does a moving car not collide with another car?", "If we disregard the moving cars that do not collide with another car, what does each moving car contribute to the answer?", "Will stationary cars contribute towards the answer?"], "metadata": {"canonical_parameter_names": ["directions"], "leetcode_dataset_entry_point": "Solution().countCollisions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:45:04+00:00", "tests_total": 177, "tests_dropped": 0, "flags": [], "topic_tags": ["string", "stack", "simulation"]}, "language": "javascript", "interface": {"raw_signature": "var countCollisions = function(directions) {", "container": null, "callable": "countCollisions", "parameters": [{"name": "directions", "type": "string"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} @@ -621,3 +620,4 @@ {"question_id": 2509, "task_id": "cycle-length-queries-in-a-tree", "difficulty": "Hard", "problem_description": "You are given an integer n. There is a complete binary tree with 2^n - 1 nodes. The root of that tree is the node with the value 1, and every node with a value val in the range [1, 2^{n - 1} - 1] has two children where:\n\n- The left node has the value 2 * val, and\n- The right node has the value 2 * val + 1.\n\nYou are also given a 2D integer array queries of length m, where queries[i] = [a_i, b_i]. For each query, solve the following problem:\n\n1. Add an edge between the nodes with values a_i and b_i.\n2. Find the length of the cycle in the graph.\n3. Remove the added edge between nodes with values a_i and b_i.\n\nNote that:\n\n- A cycle is a path that starts and ends at the same node, and each edge in the path is visited only once.\n- The length of a cycle is the number of edges visited in the cycle.\n- There could be multiple edges between two nodes in the tree after adding the edge of the query.\n\nReturn an array answer of length m where answer[i] is the answer to the i^th query.\n\nExample 1:\n\nInput: n = 3, queries = [[5,3],[4,7],[2,3]]\nOutput: [4,5,3]\nExplanation: The diagrams above show the tree of 2^3 - 1 nodes. Nodes colored in red describe the nodes in the cycle after adding the edge.\n- After adding the edge between nodes 3 and 5, the graph contains a cycle of nodes [5,2,1,3]. Thus answer to the first query is 4. We delete the added edge and process the next query.\n- After adding the edge between nodes 4 and 7, the graph contains a cycle of nodes [4,2,1,3,7]. Thus answer to the second query is 5. We delete the added edge and process the next query.\n- After adding the edge between nodes 2 and 3, the graph contains a cycle of nodes [2,1,3]. Thus answer to the third query is 3. We delete the added edge.\n\nExample 2:\n\nInput: n = 2, queries = [[1,2]]\nOutput: [2]\nExplanation: The diagram above shows the tree of 2^2 - 1 nodes. Nodes colored in red describe the nodes in the cycle after adding the edge.\n- After adding the edge between nodes 1 and 2, the graph contains a cycle of nodes [2,1]. Thus answer for the first query is 2. We delete the added edge.\n\nConstraints:\n\n- 2 <= n <= 30\n- m == queries.length\n- 1 <= m <= 10^5\n- queries[i].length == 2\n- 1 <= a_i, b_i <= 2^n - 1\n- a_i != b_i\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,queries = [[31, 15], [10, 18], [9, 20]]) == [2, 6, 6]\n assert candidate(n = 3,queries = [[5, 3], [4, 7], [2, 3]]) == [4, 5, 3]\n assert candidate(n = 5,queries = [[15, 7], [10, 14], [3, 12]]) == [2, 7, 3]\n assert candidate(n = 30,queries = [[1073741823, 1], [536870912, 2], [268435456, 4]]) == [30, 29, 27]\n assert candidate(n = 4,queries = [[8, 4], [7, 3], [1, 14]]) == [2, 2, 4]\n assert candidate(n = 4,queries = [[1, 15], [14, 2], [12, 10], [6, 3]]) == [4, 5, 7, 2]\n assert candidate(n = 2,queries = [[1, 2]]) == [2]\n assert candidate(n = 5,queries = [[3, 15], [16, 7], [8, 9]]) == [3, 7, 3]\n assert candidate(n = 6,queries = [[32, 1], [16, 15], [8, 7], [4, 3], [2, 1]]) == [6, 8, 6, 4, 2]\n assert candidate(n = 4,queries = [[8, 4], [6, 10], [5, 9]]) == [2, 6, 4]\n assert candidate(n = 19,queries = [[262144, 524287], [131072, 262143], [65536, 131071], [32768, 65535], [16384, 32767], [8192, 16383], [4096, 8191], [2048, 4095], [1024, 2047], [512, 1023], [256, 511], [128, 255], [64, 127], [32, 63], [16, 31], [8, 15], [4, 7], [2, 3]]) == [37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3]\n assert candidate(n = 10,queries = [[511, 1], [256, 2], [128, 4], [64, 8], [32, 16], [16, 32], [8, 64], [4, 128], [2, 256], [1, 511], [511, 256], [256, 128], [128, 64], [64, 32], [32, 16], [16, 8], [8, 4], [4, 2], [2, 1], [511, 510], [510, 509], [509, 508], [508, 507], [507, 506], [506, 505]]) == [9, 8, 6, 4, 2, 2, 4, 6, 8, 9, 17, 2, 2, 2, 2, 2, 2, 2, 2, 3, 5, 3, 7, 3, 5]\n assert candidate(n = 18,queries = [[131071, 1], [65536, 2], [32768, 4], [16384, 8], [8192, 16], [4096, 32], [2048, 64], [1024, 128], [512, 256], [256, 512], [128, 1024], [64, 2048], [32, 4096], [16, 8192], [8, 16384], [4, 32768], [2, 65536], [1, 131071]]) == [17, 16, 14, 12, 10, 8, 6, 4, 2, 2, 4, 6, 8, 10, 12, 14, 16, 17]\n assert candidate(n = 15,queries = [[32767, 16384], [8192, 4096], [2048, 1024], [512, 256], [128, 64]]) == [29, 2, 2, 2, 2]\n assert candidate(n = 22,queries = [[4194303, 2097152], [2097151, 1048576], [1048575, 524288], [524287, 262144], [262143, 131072], [131071, 65536], [65535, 32768], [32767, 16384], [16383, 8192]]) == [43, 41, 39, 37, 35, 33, 31, 29, 27]\n assert candidate(n = 25,queries = [[33554431, 16777216], [16777216, 8388608], [8388608, 4194304], [4194304, 2097152], [2097152, 1048576], [1048576, 524288], [524288, 262144], [262144, 131072], [131072, 65536], [65536, 32768], [32768, 16384], [16384, 8192], [8192, 4096], [4096, 2048], [2048, 1024], [1024, 512], [512, 256], [256, 128], [128, 64], [64, 32], [32, 16], [16, 8], [8, 4], [4, 2], [2, 1]]) == [49, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(n = 20,queries = [[1048575, 524288], [524287, 262144], [262143, 131072], [131071, 65536], [65535, 32768]]) == [39, 37, 35, 33, 31]\n assert candidate(n = 15,queries = [[16383, 1], [8192, 3], [4096, 7], [2048, 15], [1024, 31]]) == [14, 15, 15, 15, 15]\n assert candidate(n = 12,queries = [[4095, 1], [2047, 2], [1023, 4], [511, 8], [255, 16], [127, 32], [63, 64], [31, 128], [15, 256], [7, 512], [3, 1024], [1, 2048], [4094, 4095], [2046, 2047], [1022, 1023], [510, 511], [254, 255], [126, 127], [62, 63], [30, 31], [14, 15], [6, 7], [2, 3], [1, 2], [4093, 1], [2045, 2], [1021, 4], [509, 8], [253, 16], [125, 32], [61, 64], [30, 128], [14, 256], [6, 512], [2, 1024], [1, 2048]]) == [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 10, 12]\n assert candidate(n = 15,queries = [[16384, 32767], [8192, 16383], [4096, 8191], [2048, 4095], [1024, 2047], [512, 1023]]) == [29, 27, 25, 23, 21, 19]\n assert candidate(n = 10,queries = [[511, 256], [1023, 512], [768, 384], [255, 128], [127, 64]]) == [17, 19, 2, 15, 13]\n assert candidate(n = 10,queries = [[1023, 511], [511, 255], [255, 127], [127, 63], [63, 31], [31, 15], [15, 7], [7, 3], [3, 1]]) == [2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(n = 10,queries = [[512, 1], [256, 2], [128, 4], [64, 8], [32, 16], [16, 32], [8, 64], [4, 128], [2, 256], [1, 512]]) == [10, 8, 6, 4, 2, 2, 4, 6, 8, 10]\n assert candidate(n = 12,queries = [[4095, 2048], [2048, 1024], [1024, 512], [512, 256], [256, 128], [128, 64], [64, 32], [32, 16], [16, 8], [8, 4], [4, 2], [2, 1], [4095, 2047], [2047, 2046], [2046, 2045], [2045, 2044], [2044, 2043], [2043, 2042], [2042, 2041], [2041, 2040], [2040, 2039], [2039, 2038], [2038, 2037], [2037, 2036], [2036, 2035], [2035, 2034], [2034, 2033], [2033, 2032], [2032, 2031]]) == [23, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 5, 3, 7, 3, 5, 3, 9, 3, 5, 3, 7, 3, 5, 3, 11]\n assert candidate(n = 15,queries = [[16383, 1], [8191, 2], [4095, 4], [2047, 8], [1023, 16], [511, 32], [255, 64], [127, 128], [63, 256], [31, 512], [15, 1024], [7, 2048], [3, 4096], [1, 8192], [16382, 16383], [8190, 8191], [4094, 4095], [2046, 2047], [1022, 1023], [510, 511], [254, 255], [126, 127], [62, 63], [30, 31], [14, 15], [6, 7], [2, 3], [1, 2]]) == [14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]\n assert candidate(n = 20,queries = [[1048575, 1], [524288, 2], [262144, 4], [131072, 8], [65536, 16], [32768, 32], [16384, 64], [8192, 128], [4096, 256], [2048, 512]]) == [20, 19, 17, 15, 13, 11, 9, 7, 5, 3]\n assert candidate(n = 17,queries = [[65535, 32768], [16384, 8192], [4096, 2048], [1024, 512], [256, 128], [64, 32], [16, 8], [4, 2], [2, 1], [65535, 1], [32768, 2], [16384, 4], [8192, 8], [4096, 16], [2048, 32], [1024, 64], [512, 128]]) == [31, 2, 2, 2, 2, 2, 2, 2, 2, 16, 15, 13, 11, 9, 7, 5, 3]\n assert candidate(n = 12,queries = [[4095, 1], [2048, 3], [1024, 7], [512, 15], [256, 31], [128, 63], [64, 127], [32, 255], [16, 511], [8, 1023], [4, 2047], [2, 4095]]) == [12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]\n assert candidate(n = 27,queries = [[134217727, 67108864], [67108863, 33554432], [33554431, 16777216], [16777215, 8388608], [8388607, 4194304], [4194303, 2097152], [2097151, 1048576], [1048575, 524288], [524287, 262144], [262143, 131072], [131071, 65536], [65535, 32768], [32767, 16384], [16383, 8192], [8191, 4096], [4095, 2048], [2047, 1024], [1023, 512], [511, 256], [255, 128], [127, 64], [63, 32], [31, 16], [15, 8], [7, 4], [3, 2], [1, 2]]) == [53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 2]\n assert candidate(n = 25,queries = [[16777215, 8388608], [4194304, 2097152], [2097152, 1048576], [1048576, 524288], [524288, 262144], [262144, 131072], [131072, 65536], [65536, 32768], [32768, 16384], [16384, 8192]]) == [47, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(n = 18,queries = [[131071, 65536], [32768, 16384], [8192, 4096], [2048, 1024], [512, 256], [128, 64], [32, 16], [8, 4], [2, 1], [131071, 1], [65536, 2], [32768, 4], [16384, 8]]) == [33, 2, 2, 2, 2, 2, 2, 2, 2, 17, 16, 14, 12]\n assert candidate(n = 25,queries = [[33554431, 16777216], [16777215, 8388608], [8388607, 4194304], [4194303, 2097152], [2097151, 1048576]]) == [49, 47, 45, 43, 41]\n assert candidate(n = 10,queries = [[511, 256], [128, 64], [32, 16], [8, 4], [4, 2], [2, 1], [128, 1], [256, 32], [511, 64]]) == [17, 2, 2, 2, 2, 2, 8, 4, 15]\n assert candidate(n = 25,queries = [[33554431, 16777216], [8388608, 4194304], [2097152, 1048576], [524288, 262144], [131072, 65536]]) == [49, 2, 2, 2, 2]\n assert candidate(n = 20,queries = [[524287, 262144], [131072, 65536], [32768, 16384], [8192, 4096], [2048, 1024], [512, 256], [128, 64], [32, 16], [8, 4]]) == [37, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(n = 25,queries = [[16777216, 8388608], [8388608, 4194304], [4194304, 2097152], [2097152, 1048576], [1048576, 524288]]) == [2, 2, 2, 2, 2]\n assert candidate(n = 20,queries = [[1048575, 1], [524288, 2], [262144, 4], [131072, 8], [65536, 16]]) == [20, 19, 17, 15, 13]\n assert candidate(n = 18,queries = [[262143, 131072], [131071, 65536], [65535, 32768], [32767, 16384], [16383, 8192], [8191, 4096], [4095, 2048], [2047, 1024], [1023, 512]]) == [35, 33, 31, 29, 27, 25, 23, 21, 19]\n assert candidate(n = 18,queries = [[131072, 262143], [65536, 131071], [32768, 65535], [16384, 32767], [8192, 16383], [4096, 8191], [2048, 4095], [1024, 2047]]) == [35, 33, 31, 29, 27, 25, 23, 21]\n assert candidate(n = 25,queries = [[33554431, 16777216], [16777215, 8388608], [8388607, 4194304], [4194303, 2097152], [2097151, 1048576]]) == [49, 47, 45, 43, 41]\n assert candidate(n = 18,queries = [[262143, 1], [131072, 3], [65536, 7], [32768, 15], [16384, 31], [8192, 63], [4096, 127], [2048, 255], [1024, 511], [512, 1023], [256, 2047], [128, 4095], [64, 8191], [32, 16383], [16, 32767], [8, 65535], [4, 131071], [2, 262143]]) == [18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(n = 15,queries = [[16383, 16384], [8192, 12287], [4096, 6143], [2048, 8192], [1024, 4096]]) == [28, 25, 23, 3, 3]\n assert candidate(n = 22,queries = [[2097152, 4194303], [1048576, 2097151], [524288, 1048575], [262144, 524287], [131072, 262143], [65536, 131071], [32768, 65535], [16384, 32767]]) == [43, 41, 39, 37, 35, 33, 31, 29]\n assert candidate(n = 25,queries = [[33554431, 1], [16777216, 2], [8388608, 4], [4194304, 8], [2097152, 16], [1048576, 32], [524288, 64], [262144, 128], [131072, 256], [65536, 512], [32768, 1024], [16384, 2048], [8192, 4096], [4096, 8192], [2048, 16384], [1024, 32768], [512, 65536], [256, 131072], [128, 262144], [64, 524288], [32, 1048576], [16, 2097152], [8, 4194304], [4, 8388608], [2, 16777216]]) == [25, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]\n assert candidate(n = 20,queries = [[524288, 1048575], [262144, 524287], [131072, 262143], [65536, 131071], [32768, 65535]]) == [39, 37, 35, 33, 31]\n assert candidate(n = 16,queries = [[65535, 32768], [32767, 16384], [16383, 8192], [8191, 4096], [4095, 2048], [2047, 1024], [1023, 512], [511, 256], [255, 128], [127, 64], [63, 32], [31, 16], [15, 8], [7, 4], [3, 2], [1, 2]]) == [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 2]\n assert candidate(n = 15,queries = [[16383, 8192], [4096, 2048], [1024, 512], [256, 128], [64, 32], [16, 8], [4, 2], [2, 1]]) == [27, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(n = 12,queries = [[2048, 4095], [1024, 2047], [512, 1023], [256, 511], [128, 255], [64, 127], [32, 63], [16, 31], [8, 15], [4, 7]]) == [23, 21, 19, 17, 15, 13, 11, 9, 7, 5]\n assert candidate(n = 10,queries = [[511, 256], [255, 128], [127, 64], [63, 32], [31, 16], [15, 8], [7, 4], [3, 2], [1, 2]]) == [17, 15, 13, 11, 9, 7, 5, 3, 2]\n assert candidate(n = 10,queries = [[512, 256], [256, 128], [128, 64], [64, 32], [32, 16], [16, 8], [8, 4], [4, 2], [2, 1]]) == [2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(n = 20,queries = [[524288, 1048575], [262144, 524287], [131072, 262143], [65536, 131071], [32768, 65535], [16384, 32767]]) == [39, 37, 35, 33, 31, 29]\n", "comparison": "exact"}, "public_tests": ["3\n[[5,3],[4,7],[2,3]]", "2\n[[1,2]]"], "hints": ["Find the distance between nodes “a” and “b”.", "distance(a, b) = depth(a) + depth(b) - 2 * depth(LCA(a, b)). Where depth(a) denotes depth from root to node “a” and LCA(a, b) denotes the lowest common ancestor of nodes “a” and “b”.", "To find LCA(a, b), iterate over all ancestors of node “a” and check if it is the ancestor of node “b” too. If so, take the one with maximum depth."], "metadata": {"canonical_parameter_names": ["n", "queries"], "leetcode_dataset_entry_point": "Solution().cycleLengthQueries", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:23+00:00", "tests_total": 70, "tests_dropped": 19, "flags": ["figure_reference", "has_images"], "topic_tags": ["array", "tree", "binary-tree", "binary-lifting", "lowest-common-ancestor"]}, "language": "javascript", "interface": {"raw_signature": "var cycleLengthQueries = function(n, queries) {", "container": null, "callable": "cycleLengthQueries", "parameters": [{"name": "n", "type": "number"}, {"name": "queries", "type": "number[][]"}], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2511, "task_id": "maximum-enemy-forts-that-can-be-captured", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array forts of length n representing the positions of several forts. forts[i] can be -1, 0, or 1 where:\n\n- -1 represents there is no fort at the i^th position.\n- 0 indicates there is an enemy fort at the i^th position.\n- 1 indicates the fort at the i^th the position is under your command.\n\nNow you have decided to move your army from one of your forts at position i to an empty position j such that:\n\n- 0 <= i, j <= n - 1\n- The army travels over enemy forts only. Formally, for all k where min(i,j) < k < max(i,j), forts[k] == 0.\n\nWhile moving the army, all the enemy forts that come in the way are captured.\n\nReturn the maximum number of enemy forts that can be captured. In case it is impossible to move your army, or you do not have any fort under your command, return 0.\n\nExample 1:\n\nInput: forts = [1,0,0,-1,0,0,0,0,1]\nOutput: 4\nExplanation:\n- Moving the army from position 0 to position 3 captures 2 enemy forts, at 1 and 2.\n- Moving the army from position 8 to position 3 captures 4 enemy forts.\nSince 4 is the maximum number of enemy forts that can be captured, we return 4.\n\nExample 2:\n\nInput: forts = [0,0,1,-1]\nOutput: 0\nExplanation: Since no enemy fort can be captured, 0 is returned.\n\nConstraints:\n\n- 1 <= forts.length <= 1000\n- -1 <= forts[i] <= 1\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(forts = [1, 0, 1, 0, -1, 0, 1]) == 1\n assert candidate(forts = [-1, 0, 0, 0, 0, 1]) == 4\n assert candidate(forts = [0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(forts = [-1, 0, 0, 1, 0, 0, -1]) == 2\n assert candidate(forts = [1, -1]) == 0\n assert candidate(forts = [0, 0, 0, 0, 0]) == 0\n assert candidate(forts = [-1]) == 0\n assert candidate(forts = [0]) == 0\n assert candidate(forts = [1, 0, -1, 0, 1, 0, -1]) == 1\n assert candidate(forts = [0, 0, 0, 0]) == 0\n assert candidate(forts = [0, 1, 0, -1, 0]) == 1\n assert candidate(forts = [1, -1, 1, -1, 1, -1]) == 0\n assert candidate(forts = [-1, 1, -1, 1, -1, 1]) == 0\n assert candidate(forts = [0, 0, 1, -1]) == 0\n assert candidate(forts = [0, 1, 0, -1, 0, 1, 0]) == 1\n assert candidate(forts = [1, 1, 1, -1, -1, -1, 1]) == 0\n assert candidate(forts = [-1, 0, -1, 0, 1, 0, 1]) == 1\n assert candidate(forts = [1, 0, 0, 0, 0, -1]) == 4\n assert candidate(forts = [1, 0, 1, 0, -1, 0, -1]) == 1\n assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 1]) == 6\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, -1]) == 6\n assert candidate(forts = [1, 0, 0, -1, 0, 0, 0, 0, 1]) == 4\n assert candidate(forts = [1, 0, 0, 0, 0, 0, -1]) == 5\n assert candidate(forts = [-1, 0, 0, 0, 0, 0, 1]) == 5\n assert candidate(forts = [1]) == 0\n assert candidate(forts = [1, 1, -1, -1, 1, 1]) == 0\n assert candidate(forts = [-1, 0, -1, 0, 1, 0, -1]) == 1\n assert candidate(forts = [1, -1, 1, -1, 1]) == 0\n assert candidate(forts = [-1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, -1]) == 1\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 0\n assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, -1, 0, 0, 1, 0, 0, -1]) == 3\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 43\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 13\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 43\n assert candidate(forts = [-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1]) == 3\n assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, -1]) == 4\n assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1]) == 5\n assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 2\n assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 5\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1]) == 43\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 29\n assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 0\n assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1]) == 5\n assert candidate(forts = [-1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 5\n assert candidate(forts = [-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 0, 1]) == 4\n assert candidate(forts = [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 50\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 71\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 1]) == 7\n assert candidate(forts = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]) == 1\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 43\n assert candidate(forts = [-1, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 1, 0]) == 4\n assert candidate(forts = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]) == 7\n assert candidate(forts = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1]) == 8\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 1, -1]) == 4\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 43\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1]) == 6\n assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 1]) == 2\n assert candidate(forts = [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 8\n assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 77\n assert candidate(forts = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 5\n assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 0\n assert candidate(forts = [-1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1]) == 5\n assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 0\n assert candidate(forts = [1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, -1]) == 3\n assert candidate(forts = [1, 0, 0, -1, 0, 1, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, -1]) == 4\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, -1, 0, 0, 1, 0, 0, -1, 0, 0, 1, 0, 0, -1]) == 2\n assert candidate(forts = [1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1]) == 5\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1]) == 10\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 10\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 56\n assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 0\n assert candidate(forts = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1]) == 12\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1]) == 2\n assert candidate(forts = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(forts = [1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1]) == 5\n assert candidate(forts = [0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1]) == 5\n", "comparison": "exact"}, "public_tests": ["[1,0,0,-1,0,0,0,0,1]", "[0,0,1,-1]"], "hints": ["For each fort under your command, check if you can move the army from here.", "If yes, find the closest empty positions satisfying all criteria.", "How can two-pointers be used to solve this problem optimally?"], "metadata": {"canonical_parameter_names": ["forts"], "leetcode_dataset_entry_point": "Solution().captureForts", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:27+00:00", "tests_total": 100, "tests_dropped": 0, "flags": [], "topic_tags": ["array", "two-pointers"]}, "language": "javascript", "interface": {"raw_signature": "var captureForts = function(forts) {", "container": null, "callable": "captureForts", "parameters": [{"name": "forts", "type": "number[]"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} {"question_id": 2512, "task_id": "reward-top-k-students", "difficulty": "Medium", "problem_description": "You are given two string arrays positive_feedback and negative_feedback, containing the words denoting positive and negative feedback, respectively. Note that no word is both positive and negative.\n\nInitially every student has 0 points. Each positive word in a feedback report increases the points of a student by 3, whereas each negative word decreases the points by 1.\n\nYou are given n feedback reports, represented by a 0-indexed string array report and a 0-indexed integer array student_id, where student_id[i] represents the ID of the student who has received the feedback report report[i]. The ID of each student is unique.\n\nGiven an integer k, return the top k students after ranking them in non-increasing order by their points. In case more than one student has the same points, the one with the lower ID ranks higher.\n\nExample 1:\n\nInput: positive_feedback = [\"smart\",\"brilliant\",\"studious\"], negative_feedback = [\"not\"], report = [\"this student is studious\",\"the student is smart\"], student_id = [1,2], k = 2\nOutput: [1,2]\nExplanation:\nBoth the students have 1 positive feedback and 3 points but since student 1 has a lower ID he ranks higher.\n\nExample 2:\n\nInput: positive_feedback = [\"smart\",\"brilliant\",\"studious\"], negative_feedback = [\"not\"], report = [\"this student is not studious\",\"the student is smart\"], student_id = [1,2], k = 2\nOutput: [2,1]\nExplanation:\n- The student with ID 1 has 1 positive feedback and 1 negative feedback, so he has 3-1=2 points.\n- The student with ID 2 has 1 positive feedback, so he has 3 points.\nSince student 2 has more points, [2,1] is returned.\n\nConstraints:\n\n- 1 <= positive_feedback.length, negative_feedback.length <= 10^4\n- 1 <= positive_feedback[i].length, negative_feedback[j].length <= 100\n- Both positive_feedback[i] and negative_feedback[j] consists of lowercase English letters.\n- No word is present in both positive_feedback and negative_feedback.\n- n == report.length == student_id.length\n- 1 <= n <= 10^4\n- report[i] consists of lowercase English letters and spaces ' '.\n- There is a single space between consecutive words of report[i].\n- 1 <= report[i].length <= 100\n- 1 <= student_id[i] <= 10^9\n- All the values of student_id[i] are unique.\n- 1 <= k <= n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(positive_feedback = ['smart', 'brilliant', 'studious'],negative_feedback = ['not'],report = ['this student is studious', 'the student is smart'],student_id = [1, 2],k = 2) == [1, 2]\n assert candidate(positive_feedback = ['good', 'excellent'],negative_feedback = ['bad', 'poor'],report = ['the student is good and excellent', 'the student is bad but tries'],student_id = [3, 4],k = 1) == [3]\n assert candidate(positive_feedback = ['smart', 'brilliant', 'studious'],negative_feedback = ['not'],report = ['this student is not studious', 'the student is smart'],student_id = [1, 2],k = 2) == [2, 1]\n assert candidate(positive_feedback = ['good', 'excellent'],negative_feedback = ['bad', 'poor'],report = ['the student is good', 'the student is excellent', 'the student is bad', 'the student is poor'],student_id = [101, 102, 103, 104],k = 2) == [101, 102]\n assert candidate(positive_feedback = ['good', 'excellent'],negative_feedback = ['bad', 'poor'],report = ['the student is good and excellent', 'the student is bad'],student_id = [3, 4],k = 1) == [3]\n assert candidate(positive_feedback = ['outstanding'],negative_feedback = ['poor'],report = ['the student is outstanding', 'the student is poor', 'the student is not poor'],student_id = [100, 200, 300],k = 3) == [100, 200, 300]\n assert candidate(positive_feedback = ['good', 'great'],negative_feedback = ['average', 'terrible'],report = ['average performance', 'good work but could be better', 'terrible experience'],student_id = [301, 302, 303],k = 2) == [302, 301]\n assert candidate(positive_feedback = ['kind', 'friendly'],negative_feedback = ['rude', 'mean'],report = ['the student is kind', 'the student is mean'],student_id = [7, 8],k = 2) == [7, 8]\n assert candidate(positive_feedback = ['hardworking', 'diligent'],negative_feedback = ['lazy', 'slacker'],report = ['the student is hardworking', 'the student is diligent', 'the student is lazy', 'the student is slacker'],student_id = [501, 502, 503, 504],k = 3) == [501, 502, 503]\n assert candidate(positive_feedback = ['hardworking', 'dedicated'],negative_feedback = ['lazy', 'inattentive'],report = ['the student is hardworking and dedicated', 'the student is lazy'],student_id = [10, 20],k = 1) == [10]\n assert candidate(positive_feedback = ['helpful', 'efficient'],negative_feedback = ['lazy', 'inefficient'],report = ['the student is helpful', 'the student is lazy'],student_id = [5, 6],k = 2) == [5, 6]\n assert candidate(positive_feedback = ['excellent', 'outstanding'],negative_feedback = ['poor', 'bad'],report = ['very poor performance', 'outstanding in every aspect'],student_id = [201, 202],k = 2) == [202, 201]\n assert candidate(positive_feedback = ['adept', 'proficient'],negative_feedback = ['incompetent', 'unskilled'],report = ['the student is adept', 'the student is proficient', 'the student is incompetent', 'the student is unskilled'],student_id = [701, 702, 703, 704],k = 4) == [701, 702, 703, 704]\n assert candidate(positive_feedback = ['excellent'],negative_feedback = ['terrible'],report = ['the student is excellent', 'the student is terrible', 'the student is terrible but excellent'],student_id = [5, 15, 25],k = 2) == [5, 25]\n assert candidate(positive_feedback = ['outstanding', 'great'],negative_feedback = ['average', 'poor'],report = ['the student is average', 'the student is outstanding'],student_id = [5, 6],k = 2) == [6, 5]\n assert candidate(positive_feedback = ['hardworking', 'dedicated'],negative_feedback = ['lazy', 'slacking'],report = ['the student is lazy', 'the student is dedicated and hardworking'],student_id = [7, 8],k = 2) == [8, 7]\n assert candidate(positive_feedback = ['hardworking', 'dedicated'],negative_feedback = ['lazy', 'careless'],report = ['the student is hardworking and dedicated', 'the student is lazy but smart'],student_id = [101, 102],k = 1) == [101]\n assert candidate(positive_feedback = ['excellent', 'outstanding', 'great'],negative_feedback = ['bad', 'poor', 'terrible'],report = ['the student is excellent and great', 'the student is poor', 'the student is excellent but terrible'],student_id = [5, 3, 8],k = 2) == [5, 8]\n assert candidate(positive_feedback = ['efficient', 'productive', 'organized'],negative_feedback = ['disorganized', 'inefficient', 'unproductive'],report = ['the student is efficient and organized', 'the student is disorganized and inefficient', 'the student is productive'],student_id = [3001, 3002, 3003],k = 1) == [3001]\n assert candidate(positive_feedback = ['knowledgeable', 'informed', 'learned'],negative_feedback = ['ignorant', 'uninformed', 'naive'],report = ['the student is knowledgeable', 'the student is uninformed', 'the student is ignorant and naive'],student_id = [4001, 4002, 4003],k = 2) == [4001, 4002]\n assert candidate(positive_feedback = ['excellent', 'outstanding', 'impressive'],negative_feedback = ['poor', 'mediocre', 'inadequate'],report = ['the student is excellent and impressive', 'the student is mediocre', 'the student is excellent but also poor'],student_id = [1001, 1002, 1003],k = 3) == [1001, 1003, 1002]\n assert candidate(positive_feedback = ['innovative', 'creative', 'inspiring'],negative_feedback = ['dull', 'boring', 'unoriginal'],report = ['the student is innovative and creative', 'the student is unoriginal', 'the student is inspiring but also unoriginal'],student_id = [2001, 2002, 2003],k = 2) == [2001, 2003]\n assert candidate(positive_feedback = ['innovative', 'creative', 'original'],negative_feedback = ['conventional', 'boring', 'predictable'],report = ['the student is conventional and boring', 'the student is creative and innovative', 'the student is original but not always predictable', 'the student is predictable but hardworking'],student_id = [5001, 5002, 5003, 5004],k = 2) == [5002, 5003]\n assert candidate(positive_feedback = ['knowledgeable', 'wise', 'informed'],negative_feedback = ['ignorant', 'naive', 'uninformed'],report = ['the student is knowledgeable and wise', 'the student is ignorant and naive', 'the student is informed and smart'],student_id = [4001, 4002, 4003],k = 2) == [4001, 4003]\n assert candidate(positive_feedback = ['efficient', 'productive', 'focused'],negative_feedback = ['unfocused', 'slow', 'inconsistent'],report = ['the student is efficient', 'the student is productive', 'the student is focused'],student_id = [9001, 9002, 9003],k = 2) == [9001, 9002]\n assert candidate(positive_feedback = ['curious', 'inquisitive', 'investigative'],negative_feedback = ['ignorant', 'uninterested', 'apathetic'],report = ['the student is curious and inquisitive', 'the student is ignorant and uninterested', 'the student is investigative but needs rest'],student_id = [999, 998, 997],k = 3) == [999, 997, 998]\n assert candidate(positive_feedback = ['leader', 'motivator', 'captain'],negative_feedback = ['follower', 'lazy', 'unmotivated'],report = ['the student is leader and motivator', 'the student is follower and lazy', 'the student is captain but tired'],student_id = [777, 778, 779],k = 1) == [777]\n assert candidate(positive_feedback = ['excellent', 'outstanding', 'remarkable'],negative_feedback = ['poor', 'mediocre', 'inadequate'],report = ['the student was excellent and outstanding', 'the student was not excellent but remarkable', 'the student was poor and mediocre'],student_id = [1001, 1002, 1003],k = 3) == [1001, 1002, 1003]\n assert candidate(positive_feedback = ['outstanding', 'excellent', 'remarkable'],negative_feedback = ['poor', 'bad', 'mediocre'],report = ['the student is outstanding and excellent', 'the student is mediocre', 'the student is poor'],student_id = [1001, 1002, 1003],k = 2) == [1001, 1002]\n assert candidate(positive_feedback = ['persevering', 'determined', 'resilient'],negative_feedback = ['quitter', 'defeated', 'weak'],report = ['the student is persevering', 'the student is determined', 'the student is resilient', 'the student is a quitter', 'the student is defeated', 'the student is weak'],student_id = [3001, 3002, 3003, 3004, 3005, 3006],k = 4) == [3001, 3002, 3003, 3004]\n assert candidate(positive_feedback = ['reliable', 'trustworthy', 'dependable'],negative_feedback = ['unreliable', 'dishonest', 'untrustworthy'],report = ['the student is reliable and dependable', 'the student is unreliable and dishonest', 'the student is trustworthy but late'],student_id = [10, 20, 30],k = 1) == [10]\n assert candidate(positive_feedback = ['inspired', 'motivated', 'eager'],negative_feedback = ['disinterested', 'apathetic', 'unmotivated'],report = ['the student is inspired and eager', 'the student is disinterested', 'the student is motivated', 'the student is apathetic', 'the student is unmotivated'],student_id = [6001, 6002, 6003, 6004, 6005],k = 4) == [6001, 6003, 6002, 6004]\n assert candidate(positive_feedback = ['innovative', 'creative', 'resourceful'],negative_feedback = ['lazy', 'disorganized', 'unfocused'],report = ['the student is innovative and creative', 'the student is lazy', 'the student is disorganized', 'the student is resourceful'],student_id = [2001, 2002, 2003, 2004],k = 3) == [2001, 2004, 2002]\n assert candidate(positive_feedback = ['helpful', 'cooperative', 'supportive'],negative_feedback = ['unhelpful', 'selfish', 'uncooperative'],report = ['the student is helpful and cooperative', 'the student is selfish and unhelpful', 'the student is supportive but mediocre'],student_id = [201, 202, 203],k = 3) == [201, 203, 202]\n assert candidate(positive_feedback = ['honest', 'truthful', 'sincere'],negative_feedback = ['liar', 'deceptive', 'dishonest'],report = ['the student is honest and truthful', 'the student is liar and deceptive', 'the student is sincere but sometimes forgetful'],student_id = [888, 887, 886],k = 2) == [888, 886]\n assert candidate(positive_feedback = ['innovative', 'creative', 'inspiring'],negative_feedback = ['unoriginal', 'boring', 'stupid'],report = ['the student is innovative and creative', 'the student is unoriginal and stupid', 'the student is inspiring'],student_id = [1001, 1002, 1003],k = 2) == [1001, 1003]\n assert candidate(positive_feedback = ['kind', 'polite', 'considerate'],negative_feedback = ['rude', 'impolite'],report = ['the student is kind and polite', 'the student is impolite', 'the student is rude', 'the student is considerate', 'the student is impolite but kind'],student_id = [101, 102, 103, 104, 105],k = 4) == [101, 104, 105, 102]\n assert candidate(positive_feedback = ['helpful', 'supportive', 'collaborative'],negative_feedback = ['unfriendly', 'rude', 'impolite'],report = ['helpful and supportive', 'the student is rude', 'collaborative efforts', 'impolite behavior noted', 'supportive actions'],student_id = [4001, 4002, 4003, 4004, 4005],k = 4) == [4001, 4003, 4005, 4002]\n assert candidate(positive_feedback = ['helpful', 'generous', 'compassionate'],negative_feedback = ['selfish', 'greedy', 'harsh'],report = ['the student is generous and helpful', 'the student is harsh', 'the student is greedy'],student_id = [2001, 2002, 2003],k = 3) == [2001, 2002, 2003]\n assert candidate(positive_feedback = ['excellent', 'outstanding', 'perfect'],negative_feedback = ['bad', 'poor', 'mediocre'],report = ['this is an excellent report', 'the student is poor', 'outstanding performance', 'mediocre work'],student_id = [1001, 1002, 1003, 1004],k = 2) == [1001, 1003]\n assert candidate(positive_feedback = ['excellent', 'outstanding', 'exceptional'],negative_feedback = ['poor', 'mediocre', 'bad'],report = ['the student is excellent and outstanding', 'the student is mediocre and bad', 'the student is exceptional'],student_id = [5, 6, 7],k = 2) == [5, 7]\n assert candidate(positive_feedback = ['efficient', 'productive', 'focused'],negative_feedback = ['unfocused', 'slow', 'inconsistent'],report = ['the student is efficient and productive', 'the student is productive and focused', 'the student is productive but inconsistent'],student_id = [6001, 6002, 6003],k = 2) == [6001, 6002]\n assert candidate(positive_feedback = ['excellent', 'outstanding', 'brilliant'],negative_feedback = ['poor', 'bad', 'terrible'],report = ['the student is excellent and outstanding', 'the student is brilliant', 'the student is poor but not bad', 'the student is terrible'],student_id = [10, 20, 30, 40],k = 3) == [10, 20, 40]\n assert candidate(positive_feedback = ['helpful', 'cooperative'],negative_feedback = ['selfish', 'unhelpful'],report = ['the student is helpful and cooperative', 'the student is selfish', 'the student is unhelpful', 'the student is helpful but unhelpful'],student_id = [100, 101, 102, 103],k = 2) == [100, 103]\n assert candidate(positive_feedback = ['efficient', 'resourceful', 'innovative'],negative_feedback = ['inefficient', 'wasteful', 'unproductive'],report = ['the student is inefficient and wasteful', 'the student is resourceful and innovative', 'the student is productive but not very innovative'],student_id = [2001, 2002, 2003],k = 3) == [2002, 2003, 2001]\n assert candidate(positive_feedback = ['dynamic', 'engaged', 'motivated'],negative_feedback = ['disinterested', 'unmotivated', 'apathetic'],report = ['dynamic performance', 'disinterested in work', 'engaged', 'apathetic attitude', 'motivated', 'dynamic'],student_id = [5001, 5002, 5003, 5004, 5005, 5006],k = 5) == [5001, 5003, 5005, 5006, 5002]\n assert candidate(positive_feedback = ['outstanding', 'excellent', 'genius'],negative_feedback = ['poor', 'dull', 'lazy'],report = ['the student is brilliant and excellent', 'the student is lazy but smart', 'the student is outstanding'],student_id = [501, 502, 503],k = 3) == [501, 503, 502]\n assert candidate(positive_feedback = ['efficient', 'productive', 'effective'],negative_feedback = ['lazy', 'inefficient', 'unproductive'],report = ['the student is lazy and inefficient', 'the student is productive and efficient', 'the student is effective but tired'],student_id = [301, 302, 303],k = 2) == [302, 303]\n assert candidate(positive_feedback = ['creative', 'innovative', 'resourceful'],negative_feedback = ['dull', 'boring', 'stagnant'],report = ['the student is innovative', 'the student is dull', 'the student is resourceful', 'the student is boring'],student_id = [3001, 3002, 3003, 3004],k = 2) == [3001, 3003]\n assert candidate(positive_feedback = ['helpful', 'compassionate', 'generous'],negative_feedback = ['selfish', 'greedy', 'cruel'],report = ['the student is helpful and compassionate', 'the student is generous', 'the student is selfish', 'the student is greedy', 'the student is cruel', 'the student is generous and helpful'],student_id = [4001, 4002, 4003, 4004, 4005, 4006],k = 5) == [4001, 4006, 4002, 4003, 4004]\n assert candidate(positive_feedback = ['efficient', 'productive', 'focused'],negative_feedback = ['unfocused', 'slow', 'inconsistent'],report = ['the student is efficient', 'the student is productive and focused', 'the student is unfocused and slow'],student_id = [2001, 2002, 2003],k = 2) == [2002, 2001]\n assert candidate(positive_feedback = ['eloquent', 'articulate', 'persuasive'],negative_feedback = ['confused', 'incoherent', 'unclear'],report = ['the student was eloquent and articulate', 'the student was unclear', 'the student was incoherent but tried his best'],student_id = [4001, 4002, 4003],k = 3) == [4001, 4002, 4003]\n assert candidate(positive_feedback = ['efficient', 'effective', 'productive'],negative_feedback = ['unproductive', 'slow', 'ineffective'],report = ['efficiency was very high', 'the work was slow', 'productive', 'ineffective methods used', 'effective results achieved'],student_id = [3001, 3002, 3003, 3004, 3005],k = 3) == [3003, 3005, 3001]\n assert candidate(positive_feedback = ['leader', 'motivator', 'teamplayer'],negative_feedback = ['coward', 'antisocial', 'uncooperative'],report = ['the student is a teamplayer and leader', 'the student is antisocial and coward', 'the student is cooperative and motivator'],student_id = [2001, 2002, 2003],k = 3) == [2001, 2003, 2002]\n assert candidate(positive_feedback = ['efficient', 'productive', 'focused'],negative_feedback = ['unfocused', 'slow', 'inconsistent'],report = ['the student is efficient and productive', 'the student is productive but unfocused', 'the student is productive and focused'],student_id = [8001, 8002, 8003],k = 2) == [8001, 8003]\n assert candidate(positive_feedback = ['resilient', 'strong', 'enduring'],negative_feedback = ['fragile', 'weak', 'endless'],report = ['the student is resilient and strong', 'the student is fragile and weak', 'the student is enduring'],student_id = [5001, 5002, 5003],k = 3) == [5001, 5003, 5002]\n assert candidate(positive_feedback = ['ambitious', 'aspirational', 'driven'],negative_feedback = ['unambitious', 'disinterested', 'apathetic'],report = ['the student is ambitious', 'the student is disinterested', 'the student is driven but also apathetic'],student_id = [5001, 5002, 5003],k = 2) == [5001, 5003]\n assert candidate(positive_feedback = ['curious', 'inquisitive', 'seeking'],negative_feedback = ['apathetic', 'indifferent', 'uninterested'],report = ['the student was curious and inquisitive', 'the student was uninterested', 'the student was apathetic but showed improvement'],student_id = [5001, 5002, 5003],k = 3) == [5001, 5002, 5003]\n assert candidate(positive_feedback = ['leader', 'initiative', 'confidence'],negative_feedback = ['follower', 'shy', 'insecure'],report = ['the student is a leader and takes initiative', 'the student is shy and insecure', 'the student is confident and proactive', 'the student is a follower but eager to learn'],student_id = [6001, 6002, 6003, 6004],k = 1) == [6001]\n assert candidate(positive_feedback = ['innovative', 'creative', 'brilliant'],negative_feedback = ['incompetent', 'lazy', 'unhelpful'],report = ['the student showed innovative thinking', 'incompetent work was submitted', 'lazy performance', 'creative solutions provided'],student_id = [2001, 2002, 2003, 2004],k = 3) == [2001, 2004, 2002]\n assert candidate(positive_feedback = ['disciplined', 'focused', 'organized'],negative_feedback = ['disorganized', 'distracted', 'undisciplined'],report = ['the student is disciplined and organized', 'the student is distracted and disorganized', 'the student is focused but forgetful'],student_id = [1001, 1002, 1003],k = 3) == [1001, 1003, 1002]\n assert candidate(positive_feedback = ['compassionate', 'empathetic', 'sympathetic'],negative_feedback = ['cruel', 'heartless', 'unfeeling'],report = ['the student is compassionate and empathetic', 'the student is cruel and heartless', 'the student is sympathetic but needs rest'],student_id = [666, 667, 668],k = 3) == [666, 668, 667]\n assert candidate(positive_feedback = ['proactive', 'initiative', 'leader'],negative_feedback = ['passive', 'follower', 'inactive'],report = ['the student is proactive', 'the student is passive', 'the student is initiative', 'the student is follower', 'the student is leader', 'the student is inactive'],student_id = [8001, 8002, 8003, 8004, 8005, 8006],k = 3) == [8001, 8003, 8005]\n assert candidate(positive_feedback = ['efficient', 'effective', 'productive'],negative_feedback = ['inefficient', 'lazy', 'slow'],report = ['the student is very efficient', 'the student is lazy and inefficient', 'the student is slow but effective'],student_id = [3001, 3002, 3003],k = 2) == [3001, 3003]\n assert candidate(positive_feedback = ['friendly', 'helpful'],negative_feedback = ['rude', 'mean', 'unkind'],report = ['the student is friendly and helpful', 'the student is unkind', 'the student is mean', 'the student is rude'],student_id = [15, 20, 25, 30],k = 2) == [15, 20]\n assert candidate(positive_feedback = ['ambitious', 'determined', 'persistent'],negative_feedback = ['procrastinator', 'inconsistent', 'lazy'],report = ['the student is ambitious and determined', 'the student is persistent', 'the student is a procrastinator', 'the student is inconsistent', 'the student is lazy but persistent'],student_id = [1001, 1002, 1003, 1004, 1005],k = 4) == [1001, 1002, 1005, 1003]\n assert candidate(positive_feedback = ['efficient', 'productive', 'focused'],negative_feedback = ['unfocused', 'slow', 'inconsistent'],report = ['the student is productive', 'the student is focused', 'the student is efficient'],student_id = [10001, 10002, 10003],k = 2) == [10001, 10002]\n assert candidate(positive_feedback = ['innovative', 'creative', 'resourceful'],negative_feedback = ['mediocre', 'unoriginal', 'unresourceful'],report = ['the student is innovative', 'the student is creative and resourceful', 'the student is mediocre', 'the student is unoriginal', 'the student is unresourceful', 'the student is innovative and unresourceful'],student_id = [5001, 5002, 5003, 5004, 5005, 5006],k = 2) == [5002, 5001]\n assert candidate(positive_feedback = ['efficient', 'productive', 'focused'],negative_feedback = ['unfocused', 'distraught', 'inefficient'],report = ['the student is efficient', 'the student is unfocused', 'the student is productive', 'the student is distracted'],student_id = [5001, 5002, 5003, 5004],k = 3) == [5001, 5003, 5004]\n assert candidate(positive_feedback = ['proactive', 'ambitious', 'determined'],negative_feedback = ['lazy', 'apathetic', 'indifferent'],report = ['the student is proactive and ambitious', 'the student is lazy and apathetic', 'the student is determined and works hard', 'the student is indifferent but willing to try'],student_id = [4001, 4002, 4003, 4004],k = 3) == [4001, 4003, 4004]\n assert candidate(positive_feedback = ['innovative', 'creative', 'ingenious'],negative_feedback = ['incompetent', 'dull', 'inept'],report = ['the student is incompetent and dull', 'the student is creative and innovative', 'the student is inept but tries hard'],student_id = [150, 151, 152],k = 2) == [151, 152]\n assert candidate(positive_feedback = ['ingenious', 'creative', 'resourceful'],negative_feedback = ['uncreative', 'inefficient', 'unproductive'],report = ['the student is ingenious and creative', 'the student is unproductive', 'the student is resourceful but inefficient'],student_id = [3001, 3002, 3003],k = 1) == [3001]\n assert candidate(positive_feedback = ['diligent', 'persevering', 'tenacious'],negative_feedback = ['lazy', 'indolent', 'procrastinating'],report = ['the student is diligent and persevering', 'the student is indolent', 'the student is tenacious but lazy'],student_id = [7001, 7002, 7003],k = 2) == [7001, 7003]\n assert candidate(positive_feedback = ['hardworking', 'dedicated', 'persistent'],negative_feedback = ['lazy', 'careless', 'unreliable'],report = ['the student is hardworking and dedicated', 'the student is lazy', 'the student is careless', 'the student is unreliable', 'the student is persistent but careless'],student_id = [201, 202, 203, 204, 205],k = 3) == [201, 205, 202]\n assert candidate(positive_feedback = ['motivated', 'driven'],negative_feedback = ['apathetic', 'indifferent'],report = ['the student is motivated', 'the student is driven', 'the student is apathetic', 'the student is indifferent', 'the student is motivated but apathetic', 'the student is driven but indifferent'],student_id = [9001, 9002, 9003, 9004, 9005, 9006],k = 3) == [9001, 9002, 9005]\n assert candidate(positive_feedback = ['smart', 'brilliant', 'studious'],negative_feedback = ['not', 'lazy', 'careless'],report = ['this student is not studious', 'the student is smart', 'the student is lazy but brilliant', 'the student is careless'],student_id = [1, 2, 3, 4],k = 3) == [2, 1, 3]\n assert candidate(positive_feedback = ['outstanding', 'excellent', 'remarkable'],negative_feedback = ['poor', 'bad', 'mediocre'],report = ['the student is outstanding and excellent', 'the student is mediocre', 'the student is poor'],student_id = [1001, 1002, 1003],k = 2) == [1001, 1002]\n assert candidate(positive_feedback = ['cooperative', 'collaborative', 'teamplayer'],negative_feedback = ['uncooperative', 'selfish', 'individualistic'],report = ['the student is cooperative', 'the student is uncooperative', 'the student is collaborative', 'the student is selfish', 'the student is teamplayer', 'the student is individualistic'],student_id = [7001, 7002, 7003, 7004, 7005, 7006],k = 2) == [7001, 7003]\n assert candidate(positive_feedback = ['curious', 'knowledgeable', 'inquisitive'],negative_feedback = ['ignorant', 'naive', 'uninformed'],report = ['the student is curious', 'the student is knowledgeable', 'the student is inquisitive', 'the student is ignorant', 'the student is naive', 'the student is uninformed', 'the student is curious and knowledgeable'],student_id = [5001, 5002, 5003, 5004, 5005, 5006, 5007],k = 3) == [5007, 5001, 5002]\n assert candidate(positive_feedback = ['perseverant', 'determined', 'ambitious'],negative_feedback = ['lazy', 'indifferent', 'apathetic'],report = ['the student is perseverant and ambitious', 'the student is lazy', 'the student is indifferent', 'the student is apathetic'],student_id = [4001, 4002, 4003, 4004],k = 1) == [4001]\n assert candidate(positive_feedback = ['outstanding', 'excellent', 'impressive'],negative_feedback = ['poor', 'bad', 'mediocre'],report = ['the student is poor but trying hard', 'the student is excellent and impressive', 'the student is mediocre but not bad'],student_id = [1001, 1002, 1003],k = 2) == [1002, 1001]\n", "comparison": "exact"}, "public_tests": ["[\"smart\",\"brilliant\",\"studious\"]\n[\"not\"]\n[\"this student is studious\",\"the student is smart\"]\n[1,2]\n2", "[\"smart\",\"brilliant\",\"studious\"]\n[\"not\"]\n[\"this student is not studious\",\"the student is smart\"]\n[1,2]\n2"], "hints": ["Hash the positive and negative feedback words separately.", "Calculate the points for each student’s feedback.", "Sort the students accordingly to find the top k among them."], "metadata": {"canonical_parameter_names": ["positive_feedback", "negative_feedback", "report", "student_id", "k"], "leetcode_dataset_entry_point": "Solution().topStudents", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:30+00:00", "tests_total": 82, "tests_dropped": 1, "flags": [], "topic_tags": ["array", "hash-table", "string", "sorting", "heap-priority-queue"]}, "language": "javascript", "interface": {"raw_signature": "var topStudents = function(positive_feedback, negative_feedback, report, student_id, k) {", "container": null, "callable": "topStudents", "parameters": [{"name": "positive_feedback", "type": "string[]"}, {"name": "negative_feedback", "type": "string[]"}, {"name": "report", "type": "string[]"}, {"name": "student_id", "type": "number[]"}, {"name": "k", "type": "number"}], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2513, "task_id": "minimize-the-maximum-of-two-arrays", "difficulty": "Medium", "problem_description": "We have two arrays arr1 and arr2 which are initially empty. You need to add positive integers to them such that they satisfy all the following conditions:\n\n- arr1 contains uniqueCnt1 distinct positive integers, each of which is not divisible by divisor1.\n- arr2 contains uniqueCnt2 distinct positive integers, each of which is not divisible by divisor2.\n- No integer is present in both arr1 and arr2.\n\nGiven divisor1, divisor2, uniqueCnt1, and uniqueCnt2, return the minimum possible maximum integer that can be present in either array.\n\nExample 1:\n\nInput: divisor1 = 2, divisor2 = 7, uniqueCnt1 = 1, uniqueCnt2 = 3\nOutput: 4\nExplanation:\nWe can distribute the first 4 natural numbers into arr1 and arr2.\narr1 = [1] and arr2 = [2,3,4].\nWe can see that both arrays satisfy all the conditions.\nSince the maximum value is 4, we return it.\n\nExample 2:\n\nInput: divisor1 = 3, divisor2 = 5, uniqueCnt1 = 2, uniqueCnt2 = 1\nOutput: 3\nExplanation:\nHere arr1 = [1,2], and arr2 = [3] satisfy all conditions.\nSince the maximum value is 3, we return it.\n\nExample 3:\n\nInput: divisor1 = 2, divisor2 = 4, uniqueCnt1 = 8, uniqueCnt2 = 2\nOutput: 15\nExplanation:\nHere, the final possible arrays can be arr1 = [1,3,5,7,9,11,13,15], and arr2 = [2,6].\nIt can be shown that it is not possible to obtain a lower maximum satisfying all conditions.\n\nConstraints:\n\n- 2 <= divisor1, divisor2 <= 10^5\n- 1 <= uniqueCnt1, uniqueCnt2 < 10^9\n- 2 <= uniqueCnt1 + uniqueCnt2 <= 10^9\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(divisor1 = 2,divisor2 = 7,uniqueCnt1 = 1,uniqueCnt2 = 3) == 4\n assert candidate(divisor1 = 2,divisor2 = 4,uniqueCnt1 = 8,uniqueCnt2 = 2) == 15\n assert candidate(divisor1 = 100,divisor2 = 101,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 200019803\n assert candidate(divisor1 = 100,divisor2 = 200,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 201005025\n assert candidate(divisor1 = 5,divisor2 = 10,uniqueCnt1 = 5,uniqueCnt2 = 5) == 11\n assert candidate(divisor1 = 7,divisor2 = 11,uniqueCnt1 = 10,uniqueCnt2 = 10) == 20\n assert candidate(divisor1 = 7,divisor2 = 13,uniqueCnt1 = 10,uniqueCnt2 = 10) == 20\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 2,uniqueCnt2 = 1) == 3\n assert candidate(divisor1 = 10,divisor2 = 15,uniqueCnt1 = 5,uniqueCnt2 = 6) == 11\n assert candidate(divisor1 = 7,divisor2 = 11,uniqueCnt1 = 3,uniqueCnt2 = 7) == 10\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 100454545\n assert candidate(divisor1 = 89,divisor2 = 97,uniqueCnt1 = 60000000,uniqueCnt2 = 40000000) == 100011584\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 20,uniqueCnt2 = 25) == 45\n assert candidate(divisor1 = 23,divisor2 = 29,uniqueCnt1 = 50000000,uniqueCnt2 = 30000000) == 80120120\n assert candidate(divisor1 = 13,divisor2 = 19,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 200813008\n assert candidate(divisor1 = 2,divisor2 = 3,uniqueCnt1 = 999999999,uniqueCnt2 = 1) == 1999999997\n assert candidate(divisor1 = 100000,divisor2 = 10000,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 100001000\n assert candidate(divisor1 = 30,divisor2 = 42,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 100478468\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 10000000,uniqueCnt2 = 20000000) == 30136363\n assert candidate(divisor1 = 45,divisor2 = 18,uniqueCnt1 = 200000000,uniqueCnt2 = 300000000) == 505617977\n assert candidate(divisor1 = 5,divisor2 = 7,uniqueCnt1 = 1,uniqueCnt2 = 999999999) == 1166666665\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 250000000,uniqueCnt2 = 250000000) == 502272727\n assert candidate(divisor1 = 61,divisor2 = 71,uniqueCnt1 = 70000000,uniqueCnt2 = 30000000) == 100023094\n assert candidate(divisor1 = 12,divisor2 = 18,uniqueCnt1 = 1000,uniqueCnt2 = 1000) == 2057\n assert candidate(divisor1 = 2,divisor2 = 5,uniqueCnt1 = 500000000,uniqueCnt2 = 499999999) == 1111111109\n assert candidate(divisor1 = 4,divisor2 = 6,uniqueCnt1 = 5,uniqueCnt2 = 8) == 14\n assert candidate(divisor1 = 4,divisor2 = 6,uniqueCnt1 = 300000000,uniqueCnt2 = 200000000) == 545454545\n assert candidate(divisor1 = 10000,divisor2 = 20000,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 100005000\n assert candidate(divisor1 = 8,divisor2 = 12,uniqueCnt1 = 40000000,uniqueCnt2 = 60000000) == 104347826\n assert candidate(divisor1 = 99999,divisor2 = 99998,uniqueCnt1 = 100000,uniqueCnt2 = 100000) == 200000\n assert candidate(divisor1 = 50000,divisor2 = 100000,uniqueCnt1 = 10000000,uniqueCnt2 = 10000000) == 20000200\n assert candidate(divisor1 = 29,divisor2 = 41,uniqueCnt1 = 60000000,uniqueCnt2 = 40000000) == 100084175\n assert candidate(divisor1 = 15,divisor2 = 20,uniqueCnt1 = 75000000,uniqueCnt2 = 25000000) == 101694915\n assert candidate(divisor1 = 19,divisor2 = 23,uniqueCnt1 = 150000000,uniqueCnt2 = 150000000) == 300688073\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 107142857\n assert candidate(divisor1 = 50000,divisor2 = 75000,uniqueCnt1 = 60000000,uniqueCnt2 = 40000000) == 100000666\n assert candidate(divisor1 = 20,divisor2 = 30,uniqueCnt1 = 500000000,uniqueCnt2 = 400000000) == 915254237\n assert candidate(divisor1 = 6,divisor2 = 8,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 104347826\n assert candidate(divisor1 = 100000,divisor2 = 50000,uniqueCnt1 = 50000000,uniqueCnt2 = 40000000) == 90000900\n assert candidate(divisor1 = 10,divisor2 = 15,uniqueCnt1 = 75000000,uniqueCnt2 = 25000000) == 103448275\n assert candidate(divisor1 = 100000,divisor2 = 100000,uniqueCnt1 = 450000000,uniqueCnt2 = 450000000) == 900009000\n assert candidate(divisor1 = 23,divisor2 = 37,uniqueCnt1 = 50000000,uniqueCnt2 = 49999999) == 100117646\n assert candidate(divisor1 = 23,divisor2 = 37,uniqueCnt1 = 45000000,uniqueCnt2 = 55000000) == 100117647\n assert candidate(divisor1 = 11,divisor2 = 13,uniqueCnt1 = 100,uniqueCnt2 = 150) == 251\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 214285714\n assert candidate(divisor1 = 1000,divisor2 = 500,uniqueCnt1 = 40000000,uniqueCnt2 = 60000000) == 100100100\n assert candidate(divisor1 = 4,divisor2 = 6,uniqueCnt1 = 100000000,uniqueCnt2 = 99999999) == 218181817\n assert candidate(divisor1 = 5,divisor2 = 7,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 102941176\n assert candidate(divisor1 = 17,divisor2 = 31,uniqueCnt1 = 99999999,uniqueCnt2 = 1) == 106249998\n assert candidate(divisor1 = 99998,divisor2 = 99999,uniqueCnt1 = 100000,uniqueCnt2 = 100000) == 200000\n assert candidate(divisor1 = 10,divisor2 = 15,uniqueCnt1 = 100000000,uniqueCnt2 = 1) == 111111111\n assert candidate(divisor1 = 4,divisor2 = 6,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 218181818\n assert candidate(divisor1 = 6,divisor2 = 8,uniqueCnt1 = 75000000,uniqueCnt2 = 25000000) == 104347826\n assert candidate(divisor1 = 77,divisor2 = 42,uniqueCnt1 = 500,uniqueCnt2 = 500) == 1002\n assert candidate(divisor1 = 11,divisor2 = 13,uniqueCnt1 = 20000000,uniqueCnt2 = 15000000) == 35246478\n assert candidate(divisor1 = 7,divisor2 = 14,uniqueCnt1 = 25000000,uniqueCnt2 = 25000000) == 53846153\n assert candidate(divisor1 = 15,divisor2 = 25,uniqueCnt1 = 80000000,uniqueCnt2 = 70000000) == 152027027\n assert candidate(divisor1 = 11,divisor2 = 13,uniqueCnt1 = 99999999,uniqueCnt2 = 99999999) == 201408448\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 100,uniqueCnt2 = 200) == 321\n assert candidate(divisor1 = 25,divisor2 = 40,uniqueCnt1 = 100,uniqueCnt2 = 150) == 251\n assert candidate(divisor1 = 6,divisor2 = 9,uniqueCnt1 = 15,uniqueCnt2 = 20) == 37\n assert candidate(divisor1 = 6,divisor2 = 9,uniqueCnt1 = 50000000,uniqueCnt2 = 50000000) == 105882352\n assert candidate(divisor1 = 23,divisor2 = 31,uniqueCnt1 = 200000000,uniqueCnt2 = 300000000) == 500702247\n assert candidate(divisor1 = 5,divisor2 = 6,uniqueCnt1 = 1000000,uniqueCnt2 = 500000) == 1551724\n assert candidate(divisor1 = 67,divisor2 = 89,uniqueCnt1 = 400000000,uniqueCnt2 = 400000000) == 800134183\n assert candidate(divisor1 = 11,divisor2 = 13,uniqueCnt1 = 200000000,uniqueCnt2 = 1) == 219999999\n assert candidate(divisor1 = 37,divisor2 = 41,uniqueCnt1 = 9876543,uniqueCnt2 = 1234567) == 11118439\n assert candidate(divisor1 = 7,divisor2 = 13,uniqueCnt1 = 300000000,uniqueCnt2 = 300000000) == 606666666\n assert candidate(divisor1 = 5,divisor2 = 7,uniqueCnt1 = 99999999,uniqueCnt2 = 1) == 124999998\n assert candidate(divisor1 = 97,divisor2 = 101,uniqueCnt1 = 1000000,uniqueCnt2 = 500000) == 1500153\n assert candidate(divisor1 = 10000,divisor2 = 100000,uniqueCnt1 = 90000000,uniqueCnt2 = 10000000) == 100001000\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 5,uniqueCnt2 = 10) == 15\n assert candidate(divisor1 = 10,divisor2 = 15,uniqueCnt1 = 100000000,uniqueCnt2 = 200000000) == 310344827\n assert candidate(divisor1 = 77,divisor2 = 42,uniqueCnt1 = 33000000,uniqueCnt2 = 66000000) == 99214750\n assert candidate(divisor1 = 6,divisor2 = 8,uniqueCnt1 = 99999999,uniqueCnt2 = 1) == 119999998\n assert candidate(divisor1 = 5,divisor2 = 10,uniqueCnt1 = 50,uniqueCnt2 = 50) == 111\n assert candidate(divisor1 = 101,divisor2 = 103,uniqueCnt1 = 1000000,uniqueCnt2 = 1000000) == 2000192\n assert candidate(divisor1 = 23,divisor2 = 31,uniqueCnt1 = 50000000,uniqueCnt2 = 30000000) == 80112359\n assert candidate(divisor1 = 11,divisor2 = 22,uniqueCnt1 = 100000000,uniqueCnt2 = 1) == 109999999\n assert candidate(divisor1 = 11,divisor2 = 22,uniqueCnt1 = 300000000,uniqueCnt2 = 300000000) == 628571428\n assert candidate(divisor1 = 23,divisor2 = 29,uniqueCnt1 = 100000,uniqueCnt2 = 100000) == 200300\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 100000000,uniqueCnt2 = 50000000) == 160714285\n assert candidate(divisor1 = 5,divisor2 = 3,uniqueCnt1 = 100,uniqueCnt2 = 150) == 267\n assert candidate(divisor1 = 7,divisor2 = 11,uniqueCnt1 = 10000000,uniqueCnt2 = 10000000) == 20263157\n assert candidate(divisor1 = 4,divisor2 = 6,uniqueCnt1 = 250000000,uniqueCnt2 = 250000000) == 545454545\n assert candidate(divisor1 = 8,divisor2 = 9,uniqueCnt1 = 2000000,uniqueCnt2 = 3000000) == 5070422\n assert candidate(divisor1 = 100000,divisor2 = 99999,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 200000000\n assert candidate(divisor1 = 10,divisor2 = 25,uniqueCnt1 = 50000000,uniqueCnt2 = 100000000) == 153061224\n assert candidate(divisor1 = 5,divisor2 = 15,uniqueCnt1 = 100000000,uniqueCnt2 = 50000000) == 160714285\n assert candidate(divisor1 = 5,divisor2 = 10,uniqueCnt1 = 50000000,uniqueCnt2 = 49999999) == 111111109\n assert candidate(divisor1 = 2,divisor2 = 3,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 239999999\n assert candidate(divisor1 = 2,divisor2 = 4,uniqueCnt1 = 99999999,uniqueCnt2 = 1) == 199999997\n assert candidate(divisor1 = 17,divisor2 = 29,uniqueCnt1 = 150000000,uniqueCnt2 = 150000000) == 300609756\n assert candidate(divisor1 = 9,divisor2 = 12,uniqueCnt1 = 250000000,uniqueCnt2 = 250000000) == 514285714\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 300000000,uniqueCnt2 = 200000000) == 502272727\n assert candidate(divisor1 = 3,divisor2 = 5,uniqueCnt1 = 500000000,uniqueCnt2 = 400000000) == 964285714\n assert candidate(divisor1 = 13,divisor2 = 17,uniqueCnt1 = 100000000,uniqueCnt2 = 100000000) == 200909090\n assert candidate(divisor1 = 71,divisor2 = 73,uniqueCnt1 = 10000000,uniqueCnt2 = 10000000) == 20003859\n assert candidate(divisor1 = 99,divisor2 = 101,uniqueCnt1 = 200000000,uniqueCnt2 = 300000000) == 500050010\n assert candidate(divisor1 = 3,divisor2 = 6,uniqueCnt1 = 100,uniqueCnt2 = 200) == 359\n assert candidate(divisor1 = 10,divisor2 = 15,uniqueCnt1 = 80000000,uniqueCnt2 = 20000000) == 103448275\n", "comparison": "exact"}, "public_tests": ["2\n7\n1\n3", "3\n5\n2\n1", "2\n4\n8\n2"], "hints": ["Use binary search to find smallest maximum element.", "Add numbers divisible by x in nums2 and vice versa."], "metadata": {"canonical_parameter_names": ["divisor1", "divisor2", "uniqueCnt1", "uniqueCnt2"], "leetcode_dataset_entry_point": "Solution().minimizeSet", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:55:32+00:00", "tests_total": 108, "tests_dropped": 7, "flags": [], "topic_tags": ["math", "binary-search", "number-theory", "least-common-multiple", "inclusion-exclusion-principle"]}, "language": "javascript", "interface": {"raw_signature": "var minimizeSet = function(divisor1, divisor2, uniqueCnt1, uniqueCnt2) {", "container": null, "callable": "minimizeSet", "parameters": [{"name": "divisor1", "type": "number"}, {"name": "divisor2", "type": "number"}, {"name": "uniqueCnt1", "type": "number"}, {"name": "uniqueCnt2", "type": "number"}], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}