FPEvalDataset/LeetCodeProblem
0302
1{2 "id": 2892,3 "name": "check_if_array_is_good",4 "difficulty": "Easy",5 "link": "https://leetcode.com/problems/check-if-array-is-good/",6 "date": "1688774400000",7 "task_description": "You are given an integer array `nums`. We consider an array **good **if it is a permutation of an array `base[n]`. `base[n] = [1, 2, ..., n - 1, n, n] `(in other words, it is an array of length `n + 1` which contains `1` to `n - 1 `exactly once, plus two occurrences of `n`). For example, `base[1] = [1, 1]` and` base[3] = [1, 2, 3, 3]`. Return `true` _if the given array is good, otherwise return__ _`false`. **Note: **A permutation of integers represents an arrangement of these numbers. **Example 1:** ``` **Input:** nums = [2, 1, 3] **Output:** false **Explanation:** Since the maximum element of the array is 3, the only candidate n for which this array could be a permutation of base[n], is n = 3. However, base[3] has four elements but array nums has three. Therefore, it can not be a permutation of base[3] = [1, 2, 3, 3]. So the answer is false. ``` **Example 2:** ``` **Input:** nums = [1, 3, 3, 2] **Output:** true **Explanation:** Since the maximum element of the array is 3, the only candidate n for which this array could be a permutation of base[n], is n = 3. It can be seen that nums is a permutation of base[3] = [1, 2, 3, 3] (by swapping the second and fourth elements in nums, we reach base[3]). Therefore, the answer is true. ``` **Example 3:** ``` **Input:** nums = [1, 1] **Output:** true **Explanation:** Since the maximum element of the array is 1, the only candidate n for which this array could be a permutation of base[n], is n = 1. It can be seen that nums is a permutation of base[1] = [1, 1]. Therefore, the answer is true. ``` **Example 4:** ``` **Input:** nums = [3, 4, 4, 1, 2, 1] **Output:** false **Explanation:** Since the maximum element of the array is 4, the only candidate n for which this array could be a permutation of base[n], is n = 4. However, base[4] has five elements but array nums has six. Therefore, it can not be a permutation of base[4] = [1, 2, 3, 4, 4]. So the answer is false. ``` **Constraints:** `1 <= nums.length <= 100` `1 <= num[i] <= 200`",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "nums = [2, 1, 3]",12 "output": "false "13 },14 {15 "label": "Example 2",16 "input": "nums = [1, 3, 3, 2]",17 "output": "true "18 },19 {20 "label": "Example 3",21 "input": "nums = [1, 1]",22 "output": "true "23 },24 {25 "label": "Example 4",26 "input": "nums = [3, 4, 4, 1, 2, 1]",27 "output": "false "28 }29 ],30 "private_test_cases": [31 {32 "input": [33 43,34 16,35 46,36 25,37 29,38 12,39 23,40 27,41 9,42 36,43 8,44 11,45 52,46 17,47 3,48 50,49 35,50 51,51 31,52 20,53 33,54 22,55 26,56 37,57 21,58 34,59 47,60 41,61 28,62 18,63 15,64 2,65 44,66 4,67 6,68 10,69 39,70 19,71 40,72 32,73 30,74 1,75 24,76 7,77 13,78 48,79 5,80 49,81 14,82 38,83 45,84 4285 ],86 "output": false87 },88 {89 "input": [90 5,91 1,92 2,93 4,94 395 ],96 "output": false97 },98 {99 "input": [100 12,101 8,102 5,103 4,104 19,105 16,106 7,107 9,108 13,109 11,110 10,111 14,112 17,113 3,114 2,115 18,116 15,117 6,118 1119 ],120 "output": false121 },122 {123 "input": [124 24,125 1,126 31,127 32,128 16,129 37,130 3,131 81,132 50,133 52,134 4,135 55,136 69,137 80,138 41,139 45,140 42,141 60,142 59,143 19,144 18,145 40,146 7,147 61,148 8,149 34,150 22,151 20,152 75,153 48,154 77,155 72,156 76,157 78,158 63,159 25,160 15,161 65,162 35,163 53,164 39,165 11,166 57,167 5,168 58,169 47,170 26,171 62,172 10,173 28,174 29,175 14,176 71,177 33,178 82,179 83,180 44,181 66,182 79,183 17,184 38,185 68,186 23,187 6,188 30,189 54,190 64,191 2,192 43,193 67,194 36,195 74,196 21,197 13,198 70,199 9,200 51,201 49,202 27,203 46,204 12,205 73,206 56207 ],208 "output": false209 },210 {211 "input": [212 2,213 85,214 84,215 18,216 65,217 63,218 23,219 19,220 81,221 5,222 49,223 60,224 26,225 9,226 7,227 61,228 39,229 62,230 35,231 4,232 21,233 76,234 44,235 73,236 54,237 69,238 47,239 11,240 59,241 55,242 89,243 80,244 50,245 83,246 33,247 57,248 25,249 3,250 68,251 75,252 64,253 16,254 22,255 42,256 1,257 29,258 17,259 31,260 37,261 40,262 45,263 51,264 13,265 43,266 86,267 30,268 52,269 41,270 82,271 10,272 53,273 14,274 38,275 15,276 32,277 28,278 72,279 77,280 56,281 58,282 34,283 79,284 70,285 90,286 88,287 24,288 87,289 48,290 20,291 12,292 66,293 78,294 27,295 91,296 71,297 6,298 8,299 67,300 36,301 74,302 46303 ],304 "output": false305 },306 {307 "input": [308 33,309 92,310 94,311 81,312 22,313 60,314 23,315 88,316 29,317 31,318 1,319 42,320 83,321 9,322 16,323 21,324 19,325 51,326 86,327 52,328 17,329 57,330 43,331 18,332 67,333 46,334 13,335 54,336 89,337 69,338 11,339 27,340 28,341 85,342 50,343 30,344 80,345 56,346 34,347 79,348 55,349 72,350 36,351 62,352 87,353 84,354 49,355 58,356 90,357 47,358 75,359 66,360 7,361 14,362 71,363 40,364 93,365 77,366 70,367 38,368 32,369 61,370 24,371 39,372 45,373 44,374 48,375 68,376 5,377 65,378 76,379 10,380 35,381 6,382 78,383 95,384 41,385 3,386 64,387 73,388 91,389 20,390 15,391 82,392 74,393 37,394 63,395 2,396 12,397 8,398 26,399 59,400 25,401 4,402 53403 ],404 "output": false405 },406 {407 "input": [408 7,409 13,410 24,411 22,412 15,413 4,414 25,415 6,416 20,417 9,418 17,419 3,420 12,421 18,422 21,423 14,424 1,425 2,426 8,427 5,428 16,429 19,430 10,431 23,432 11,433 25434 ],435 "output": true436 },437 {438 "input": [439 12,440 3,441 4,442 8,443 16,444 17,445 2,446 9,447 13,448 7,449 18,450 1,451 11,452 14,453 5,454 10,455 6,456 15457 ],458 "output": false459 },460 {461 "input": [462 1,463 5,464 17,465 10,466 9,467 11,468 14,469 20,470 3,471 18,472 6,473 7,474 12,475 19,476 15,477 13,478 4,479 2,480 8,481 16482 ],483 "output": false484 },485 {486 "input": [487 6,488 67,489 70,490 21,491 75,492 53,493 48,494 16,495 77,496 66,497 74,498 26,499 38,500 30,501 4,502 32,503 56,504 63,505 55,506 81,507 44,508 46,509 54,510 60,511 72,512 57,513 65,514 19,515 37,516 52,517 27,518 50,519 78,520 59,521 39,522 8,523 12,524 13,525 58,526 20,527 68,528 10,529 76,530 49,531 34,532 79,533 9,534 71,535 14,536 28,537 42,538 45,539 61,540 5,541 31,542 29,543 36,544 7,545 41,546 24,547 3,548 15,549 17,550 2,551 40,552 22,553 33,554 80,555 25,556 73,557 18,558 64,559 51,560 11,561 69,562 47,563 23,564 35,565 43,566 1,567 62568 ],569 "output": false570 }571 ],572 "haskell_template": "isGood :: [Int] -> Bool\nisGood nums ",573 "ocaml_template": "let isGood (nums: int list) : bool = ",574 "scala_template": "def isGood(nums: List[Int]): Boolean = { \n \n}",575 "java_template": "public static boolean isGood(List<Integer> nums) {\n\n}",576 "python_template": "class Solution(object):\n def isGood(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: bool\n \"\"\"\n "577}