CoolFace
Datasetpublic

FPEvalDataset/LeetCodeProblem

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes305downloads
1{2    "id": 3165,3    "name": "find_indices_with_index_and_value_difference_i",4    "difficulty": "Easy",5    "link": "https://leetcode.com/problems/find-indices-with-index-and-value-difference-i/",6    "date": "2023-10-08 00:00:00",7    "task_description": "You are given a **0-indexed** integer array `nums` having length `n`, an integer `indexDifference`, and an integer `valueDifference`. Your task is to find **two** indices `i` and `j`, both in the range `[0, n - 1]`, that satisfy the following conditions: `abs(i - j) >= indexDifference`, and `abs(nums[i] - nums[j]) >= valueDifference` Return _an integer array_ `answer`, _where_ `answer = [i, j]` _if there are two such indices_, _and_ `answer = [-1, -1]` _otherwise_. If there are multiple choices for the two indices, return _any of them_. **Note:** `i` and `j` may be **equal**. **Example 1:** ``` **Input:** nums = [5,1,4,1], indexDifference = 2, valueDifference = 4 **Output:** [0,3] **Explanation:** In this example, i = 0 and j = 3 can be selected. abs(0 - 3) >= 2 and abs(nums[0] - nums[3]) >= 4. Hence, a valid answer is [0,3]. [3,0] is also a valid answer. ``` **Example 2:** ``` **Input:** nums = [2,1], indexDifference = 0, valueDifference = 0 **Output:** [0,0] **Explanation:** In this example, i = 0 and j = 0 can be selected. abs(0 - 0) >= 0 and abs(nums[0] - nums[0]) >= 0. Hence, a valid answer is [0,0]. Other valid answers are [0,1], [1,0], and [1,1]. ``` **Example 3:** ``` **Input:** nums = [1,2,3], indexDifference = 2, valueDifference = 4 **Output:** [-1,-1] **Explanation:** In this example, it can be shown that it is impossible to find two indices that satisfy both conditions. Hence, [-1,-1] is returned. ``` **Constraints:** `1 <= n == nums.length <= 100` `0 <= nums[i] <= 50` `0 <= indexDifference <= 100` `0 <= valueDifference <= 50`",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "nums = [5,1,4,1], indexDifference = 2, valueDifference = 4",12            "output": "[0,3] "13        },14        {15            "label": "Example 2",16            "input": "nums = [2,1], indexDifference = 0, valueDifference = 0",17            "output": "[0,0] "18        },19        {20            "label": "Example 3",21            "input": "nums = [1,2,3], indexDifference = 2, valueDifference = 4",22            "output": "[-1,-1] "23        }24    ],25    "private_test_cases": [26        {27            "input": [28                [29                    39,30                    4,31                    3,32                    36,33                    19,34                    40,35                    18,36                    16,37                    9,38                    33,39                    28,40                    23,41                    16,42                    32,43                    0,44                    32,45                    14,46                    42,47                    43,48                    39,49                    40,50                    47,51                    3052                ],53                37,54                3655            ],56            "output": [57                -1,58                -159            ]60        },61        {62            "input": [63                [64                    26,65                    11,66                    43,67                    36,68                    33,69                    21,70                    16,71                    31,72                    34,73                    9,74                    7,75                    20,76                    46,77                    38,78                    3,79                    13,80                    41,81                    40,82                    30,83                    7,84                    36,85                    20,86                    5,87                    39,88                    16,89                    37,90                    10,91                    39,92                    42,93                    45,94                    4795                ],96                21,97                498            ],99            "output": [100                0,101                21102            ]103        },104        {105            "input": [106                [107                    48,108                    28,109                    26,110                    42,111                    29,112                    38,113                    23,114                    28,115                    43,116                    41,117                    19,118                    2,119                    1,120                    17,121                    27,122                    33,123                    36,124                    8,125                    39,126                    11,127                    18,128                    9,129                    27,130                    12,131                    10,132                    27,133                    33,134                    15,135                    29,136                    37,137                    27,138                    41,139                    27,140                    39,141                    10,142                    6,143                    49,144                    45,145                    37,146                    3,147                    28,148                    40,149                    13,150                    31,151                    23,152                    17,153                    37,154                    21,155                    33,156                    36,157                    25,158                    14,159                    50,160                    48,161                    24,162                    49,163                    34,164                    14,165                    17,166                    24,167                    14,168                    34,169                    5170                ],171                94,172                24173            ],174            "output": [175                -1,176                -1177            ]178        },179        {180            "input": [181                [182                    5,183                    35,184                    43,185                    11,186                    16,187                    25,188                    27,189                    9,190                    32,191                    9,192                    23,193                    24,194                    13,195                    26,196                    35,197                    18,198                    4,199                    39,200                    45,201                    49,202                    37,203                    43,204                    8,205                    46,206                    32,207                    48,208                    27,209                    34,210                    40,211                    18,212                    14,213                    30,214                    40,215                    7,216                    14,217                    17,218                    48,219                    37,220                    26,221                    6,222                    3,223                    23,224                    37,225                    8,226                    29,227                    39,228                    2,229                    20,230                    19,231                    38,232                    21,233                    36,234                    11,235                    31236                ],237                33,238                34239            ],240            "output": [241                0,242                36243            ]244        },245        {246            "input": [247                [248                    11,249                    13,250                    44,251                    31,252                    36,253                    47,254                    29,255                    20,256                    3,257                    44,258                    49,259                    19,260                    7,261                    31,262                    1,263                    17,264                    33,265                    35,266                    41,267                    48,268                    11,269                    3,270                    40,271                    22,272                    28,273                    30,274                    48,275                    31,276                    43,277                    15,278                    32,279                    47,280                    28,281                    45,282                    17,283                    22,284                    35,285                    28,286                    32,287                    31,288                    33289                ],290                46,291                29292            ],293            "output": [294                -1,295                -1296            ]297        },298        {299            "input": [300                [301                    12,302                    6,303                    0,304                    37,305                    17,306                    29,307                    32,308                    46,309                    45,310                    29,311                    50,312                    47,313                    12,314                    24,315                    43,316                    42,317                    10,318                    18,319                    13,320                    42,321                    10,322                    9,323                    43,324                    16,325                    34,326                    41,327                    37,328                    31,329                    10,330                    33,331                    11,332                    3,333                    40,334                    44,335                    44,336                    27,337                    46,338                    43,339                    24,340                    19,341                    25,342                    0,343                    13,344                    3,345                    27,346                    42,347                    35,348                    10,349                    25,350                    41,351                    31,352                    30,353                    37,354                    31,355                    38,356                    44,357                    7,358                    21,359                    47,360                    50,361                    24,362                    47363                ],364                96,365                37366            ],367            "output": [368                -1,369                -1370            ]371        },372        {373            "input": [374                [375                    34,376                    19,377                    46,378                    18,379                    46,380                    44,381                    47,382                    46,383                    12,384                    3,385                    48,386                    14,387                    3,388                    39,389                    30,390                    49,391                    45,392                    14,393                    36,394                    27,395                    19,396                    19,397                    1,398                    43,399                    12,400                    18,401                    11,402                    14,403                    39,404                    50,405                    6,406                    36,407                    38,408                    48,409                    5,410                    49,411                    19,412                    27,413                    35,414                    16,415                    12,416                    14,417                    14,418                    45,419                    27,420                    29,421                    11,422                    43,423                    40,424                    17,425                    22,426                    46,427                    11,428                    42,429                    10,430                    42,431                    24,432                    40,433                    14,434                    19,435                    45,436                    20,437                    14,438                    36,439                    36,440                    47,441                    27,442                    44,443                    7,444                    17,445                    44,446                    37,447                    39,448                    12,449                    29,450                    45451                ],452                26,453                34454            ],455            "output": [456                2,457                30458            ]459        },460        {461            "input": [462                [463                    43,464                    50,465                    39,466                    22,467                    8,468                    19,469                    0,470                    39,471                    41,472                    26,473                    38,474                    38,475                    9,476                    31,477                    37,478                    43,479                    42,480                    41,481                    11,482                    17,483                    48,484                    18,485                    16,486                    48,487                    5,488                    3,489                    41,490                    33,491                    46,492                    0,493                    25,494                    0,495                    36,496                    18,497                    23,498                    28,499                    2,500                    46,501                    38,502                    11,503                    24,504                    44,505                    32,506                    6,507                    36,508                    16,509                    15,510                    48,511                    45,512                    46,513                    9,514                    12,515                    15516                ],517                45,518                19519            ],520            "output": [521                0,522                45523            ]524        },525        {526            "input": [527                [528                    38,529                    15,530                    22,531                    14,532                    18,533                    14,534                    14,535                    39,536                    5,537                    20,538                    13,539                    45,540                    8,541                    43,542                    14,543                    40,544                    39,545                    23,546                    48,547                    35,548                    26,549                    17,550                    33,551                    40,552                    37,553                    33,554                    5,555                    18,556                    11,557                    37,558                    14,559                    1,560                    48,561                    27,562                    24,563                    47,564                    0,565                    41,566                    32,567                    50,568                    7,569                    39,570                    25,571                    22,572                    8,573                    42,574                    20,575                    24,576                    39,577                    12,578                    42,579                    14,580                    33,581                    6,582                    45,583                    28,584                    27,585                    21,586                    50,587                    17,588                    10,589                    35,590                    39,591                    5,592                    20,593                    44,594                    19,595                    10,596                    19,597                    0,598                    14,599                    22,600                    50,601                    48,602                    11,603                    25,604                    44,605                    41,606                    11,607                    15,608                    30609                ],610                37,611                18612            ],613            "output": [614                1,615                39616            ]617        },618        {619            "input": [620                [621                    6,622                    49,623                    23,624                    39,625                    6,626                    12,627                    25,628                    7,629                    9,630                    12,631                    11,632                    22,633                    4,634                    21,635                    6,636                    7,637                    3,638                    5,639                    36,640                    37,641                    29,642                    49,643                    26,644                    3,645                    32,646                    12,647                    6648                ],649                20,650                25651            ],652            "output": [653                0,654                21655            ]656        }657    ],658    "haskell_template": "findIndices :: [Int] -> Int -> Int -> [Int]\nfindIndices nums indexDifference valueDifference ",659    "ocaml_template": "let findIndices (nums: int list) (indexDifference: int) (valueDifference: int) : int list =  ",660    "scala_template": "def findIndices(nums: List[Int],indexDifference: Int,valueDifference: Int): List[Int] = { \n    \n}",661    "java_template": "class Solution {\n    public int[] findIndices(int[] nums, int indexDifference, int valueDifference) {\n        \n    }\n}",662    "python_template": "class Solution(object):\n    def findIndices(self, nums, indexDifference, valueDifference):\n        \"\"\"\n        :type nums: List[int]\n        :type indexDifference: int\n        :type valueDifference: int\n        :rtype: List[int]\n        \"\"\"\n        "663}