CoolFace
Datasetpublic

TheRealSamuel/LeetCodeProblem

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes561downloads
1{2    "id": 3705,3    "name": "find_the_largest_almost_missing_integer",4    "difficulty": "Easy",5    "link": "https://leetcode.com/problems/find-the-largest-almost-missing-integer/",6    "date": "2025-02-23 00:00:00",7    "task_description": "You are given an integer array `nums` and an integer `k`. An integer `x` is **almost missing** from `nums` if `x` appears in _exactly_ one subarray of size `k` within `nums`. Return the largest **almost missing** integer from `nums`. If no such integer exists, return `-1`. A **subarray** is a contiguous sequence of elements within an array. **Example 1:** **Input:** nums = [3,9,2,1,7], k = 3 **Output:** 7 **Explanation:** 1 appears in 2 subarrays of size 3: `[9, 2, 1]` and `[2, 1, 7]`. 2 appears in 3 subarrays of size 3: `[3, 9, 2]`, `[9, 2, 1]`, `[2, 1, 7]`. 3 appears in 1 subarray of size 3: `[3, 9, 2]`. 7 appears in 1 subarray of size 3: `[2, 1, 7]`. 9 appears in 2 subarrays of size 3: `[3, 9, 2]`, and `[9, 2, 1]`. We return 7 since it is the largest integer that appears in exactly one subarray of size `k`. **Example 2:** **Input:** nums = [3,9,7,2,1,7], k = 4 **Output:** 3 **Explanation:** 1 appears in 2 subarrays of size 4: `[9, 7, 2, 1]`, `[7, 2, 1, 7]`. 2 appears in 3 subarrays of size 4: `[3, 9, 7, 2]`, `[9, 7, 2, 1]`, `[7, 2, 1, 7]`. 3 appears in 1 subarray of size 4: `[3, 9, 7, 2]`. 7 appears in 3 subarrays of size 4: `[3, 9, 7, 2]`, `[9, 7, 2, 1]`, `[7, 2, 1, 7]`. 9 appears in 2 subarrays of size 4: `[3, 9, 7, 2]`, `[9, 7, 2, 1]`. We return 3 since it is the largest and only integer that appears in exactly one subarray of size `k`. **Example 3:** **Input:** nums = [0,0], k = 1 **Output:** -1 **Explanation:** There is no integer that appears in only one subarray of size 1. **Constraints:** `1 <= nums.length <= 50` `0 <= nums[i] <= 50` `1 <= k <= nums.length`",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "nums = [3,9,2,1,7], k = 3",12            "output": "7 "13        },14        {15            "label": "Example 2",16            "input": "nums = [3,9,7,2,1,7], k = 4",17            "output": "3 "18        },19        {20            "label": "Example 3",21            "input": "nums = [0,0], k = 1",22            "output": "-1 "23        }24    ],25    "private_test_cases": [26        {27            "input": [28                [29                    6,30                    8,31                    14,32                    7,33                    24,34                    43,35                    43,36                    48,37                    16,38                    30,39                    10,40                    36,41                    34,42                    2,43                    9,44                    19,45                    2,46                    37,47                    3648                ],49                350            ],51            "output": 652        },53        {54            "input": [55                [56                    30,57                    49,58                    42,59                    15,60                    48,61                    19,62                    21,63                    31,64                    1,65                    3,66                    15,67                    38,68                    17,69                    46,70                    23,71                    42,72                    37,73                    28,74                    14,75                    14,76                    5,77                    0,78                    15,79                    30,80                    6,81                    21,82                    19,83                    15,84                    3785                ],86                1987            ],88            "output": -189        },90        {91            "input": [92                [93                    33,94                    25,95                    46,96                    21,97                    30,98                    32,99                    49,100                    24,101                    9,102                    13,103                    16,104                    6,105                    16,106                    22,107                    30,108                    48,109                    13,110                    31,111                    13,112                    34,113                    26,114                    1,115                    45,116                    45,117                    22,118                    11,119                    38,120                    10,121                    38,122                    12,123                    15,124                    27,125                    10126                ],127                26128            ],129            "output": 33130        },131        {132            "input": [133                [134                    18,135                    49,136                    2,137                    10,138                    38,139                    21,140                    5,141                    24,142                    30,143                    50,144                    22,145                    37,146                    28,147                    15,148                    40,149                    19,150                    2,151                    5,152                    50,153                    18,154                    21,155                    26,156                    12,157                    12,158                    38,159                    7,160                    39,161                    12,162                    34163                ],164                20165            ],166            "output": 34167        },168        {169            "input": [170                [171                    32,172                    47,173                    9,174                    39,175                    19,176                    40,177                    16,178                    10,179                    21,180                    11,181                    40,182                    32,183                    33,184                    7,185                    47,186                    12,187                    37,188                    29,189                    42,190                    37,191                    6,192                    40,193                    30,194                    31,195                    47,196                    24,197                    11,198                    16,199                    39,200                    5,201                    23,202                    44,203                    48,204                    31,205                    37,206                    13,207                    33,208                    8,209                    6,210                    32,211                    49,212                    48,213                    25,214                    9,215                    29,216                    45,217                    22,218                    19,219                    28,220                    44221                ],222                21223            ],224            "output": -1225        },226        {227            "input": [228                [229                    4,230                    22,231                    26,232                    40,233                    22,234                    1,235                    27,236                    42,237                    11,238                    19,239                    40,240                    23241                ],242                4243            ],244            "output": 23245        },246        {247            "input": [248                [249                    43250                ],251                1252            ],253            "output": 43254        },255        {256            "input": [257                [258                    48,259                    19,260                    27,261                    4,262                    8,263                    10,264                    44,265                    31,266                    47,267                    8,268                    14,269                    0,270                    33,271                    11,272                    46,273                    16,274                    13,275                    5,276                    0,277                    16,278                    19,279                    19,280                    13,281                    21282                ],283                7284            ],285            "output": 48286        },287        {288            "input": [289                [290                    9,291                    2,292                    9,293                    17,294                    6,295                    46,296                    7,297                    37,298                    25,299                    1,300                    48,301                    17,302                    43,303                    37,304                    0,305                    46,306                    27,307                    40,308                    17,309                    44,310                    38,311                    13,312                    29,313                    35,314                    12,315                    39,316                    12,317                    7,318                    48,319                    23,320                    40,321                    44,322                    6,323                    12324                ],325                23326            ],327            "output": -1328        },329        {330            "input": [331                [332                    50,333                    44,334                    13,335                    26,336                    25,337                    11,338                    23,339                    44,340                    0,341                    45,342                    1,343                    38,344                    9,345                    11,346                    17347                ],348                10349            ],350            "output": 50351        }352    ],353    "haskell_template": "largestInteger :: [Int] -> Int -> Int\nlargestInteger nums k ",354    "ocaml_template": "let largestInteger (nums: int list) (k: int) : int =  ",355    "scala_template": "def largestInteger(nums: List[Int],k: Int): Int = { \n    \n}",356    "java_template": "class Solution {\n    public int largestInteger(int[] nums, int k) {\n        \n    }\n}",357    "python_template": "class Solution(object):\n    def largestInteger(self, nums, k):\n        \"\"\"\n        :type nums: List[int]\n        :type k: int\n        :rtype: int\n        \"\"\"\n        "358}