CoolFace
Datasetpublic

TheRealSamuel/LeetCodeProblem

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes564downloads
meta.json1699 linesDownload Raw Back to most_frequent_ids
1{2    "id": 3363,3    "name": "most_frequent_ids",4    "difficulty": "Medium",5    "link": "https://leetcode.com/problems/most-frequent-ids/",6    "date": "2024-03-17 00:00:00",7    "task_description": "The problem involves tracking the frequency of IDs in a collection that changes over time. You have two integer arrays, `nums` and `freq`, of equal length `n`. Each element in `nums` represents an ID, and the corresponding element in `freq` indicates how many times that ID should be added to or removed from the collection at each step. **Addition of IDs:** If `freq[i]` is positive, it means `freq[i]` IDs with the value `nums[i]` are added to the collection at step `i`. **Removal of IDs:** If `freq[i]` is negative, it means `-freq[i]` IDs with the value `nums[i]` are removed from the collection at step `i`. Return an array `ans` of length `n`, where `ans[i]` represents the **count** of the _most frequent ID_ in the collection after the `ith` step. If the collection is empty at any step, `ans[i]` should be 0 for that step. **Example 1:** **Input:** nums = [2,3,2,1], freq = [3,2,-3,1] **Output:** [3,3,2,2] **Explanation:** After step 0, we have 3 IDs with the value of 2. So `ans[0] = 3`. After step 1, we have 3 IDs with the value of 2 and 2 IDs with the value of 3. So `ans[1] = 3`. After step 2, we have 2 IDs with the value of 3. So `ans[2] = 2`. After step 3, we have 2 IDs with the value of 3 and 1 ID with the value of 1. So `ans[3] = 2`. **Example 2:** **Input:** nums = [5,5,3], freq = [2,-2,1] **Output:** [2,0,1] **Explanation:** After step 0, we have 2 IDs with the value of 5. So `ans[0] = 2`. After step 1, there are no IDs. So `ans[1] = 0`. After step 2, we have 1 ID with the value of 3. So `ans[2] = 1`. **Constraints:** `1 <= nums.length == freq.length <= 105` `1 <= nums[i] <= 105` `-105 <= freq[i] <= 105` `freq[i] != 0` The input is generated such that the occurrences of an ID will not be negative in any step.",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "nums = [2,3,2,1], freq = [3,2,-3,1]",12            "output": "[3,3,2,2] "13        },14        {15            "label": "Example 2",16            "input": "nums = [5,5,3], freq = [2,-2,1]",17            "output": "[2,0,1] "18        }19    ],20    "private_test_cases": [21        {22            "input": [23                [24                    10,25                    38,26                    26,27                    63,28                    94,29                    42,30                    11,31                    30,32                    43,33                    98,34                    77,35                    86,36                    4,37                    49,38                    2,39                    36,40                    6,41                    33,42                    4,43                    2,44                    78,45                    9,46                    51,47                    96,48                    24,49                    97,50                    15,51                    100,52                    86,53                    42,54                    78,55                    49,56                    42,57                    1,58                    47,59                    8,60                    20,61                    33,62                    40,63                    72,64                    70,65                    34,66                    18,67                    12,68                    45,69                    28,70                    7,71                    60,72                    65,73                    38,74                    96,75                    3776                ],77                [78                    2,79                    9,80                    7,81                    4,82                    8,83                    9,84                    1,85                    7,86                    9,87                    4,88                    2,89                    5,90                    6,91                    7,92                    5,93                    2,94                    9,95                    1,96                    5,97                    7,98                    8,99                    6,100                    2,101                    9,102                    7,103                    4,104                    7,105                    7,106                    10,107                    -8,108                    5,109                    2,110                    6,111                    9,112                    3,113                    7,114                    7,115                    3,116                    3,117                    10,118                    1,119                    1,120                    1,121                    7,122                    3,123                    5,124                    7,125                    2,126                    7,127                    9,128                    -2,129                    4130                ]131            ],132            "output": [133                2,134                9,135                9,136                9,137                9,138                9,139                9,140                9,141                9,142                9,143                9,144                9,145                9,146                9,147                9,148                9,149                9,150                9,151                11,152                12,153                12,154                12,155                12,156                12,157                12,158                12,159                12,160                12,161                15,162                15,163                15,164                15,165                15,166                15,167                15,168                15,169                15,170                15,171                15,172                15,173                15,174                15,175                15,176                15,177                15,178                15,179                15,180                15,181                15,182                18,183                18,184                18185            ]186        },187        {188            "input": [189                [190                    81,191                    41,192                    19,193                    14,194                    69,195                    22,196                    59,197                    25,198                    86,199                    8,200                    65,201                    67,202                    40,203                    58,204                    79,205                    40,206                    45,207                    58,208                    71,209                    57,210                    70,211                    55,212                    27,213                    4,214                    90,215                    68,216                    99,217                    73,218                    4,219                    96,220                    20,221                    73,222                    29,223                    96,224                    95,225                    17,226                    78,227                    70,228                    41,229                    41,230                    41,231                    49,232                    84,233                    12,234                    36,235                    6,236                    32,237                    63,238                    55,239                    88,240                    27,241                    27,242                    77,243                    76,244                    60,245                    24,246                    16,247                    12,248                    6,249                    51,250                    32,251                    83,252                    39,253                    13,254                    88,255                    3,256                    52,257                    55,258                    84,259                    58,260                    16,261                    28,262                    25,263                    56,264                    24,265                    100,266                    89,267                    98,268                    53,269                    34,270                    6,271                    75,272                    33,273                    51,274                    3,275                    30,276                    86,277                    17,278                    82,279                    97,280                    54,281                    13,282                    28,283                    70,284                    69,285                    24,286                    92,287                    8,288                    76,289                    45290                ],291                [292                    5,293                    6,294                    5,295                    10,296                    2,297                    8,298                    2,299                    2,300                    3,301                    9,302                    3,303                    3,304                    5,305                    4,306                    5,307                    -5,308                    10,309                    -4,310                    3,311                    3,312                    4,313                    1,314                    4,315                    2,316                    5,317                    9,318                    7,319                    9,320                    1,321                    4,322                    3,323                    6,324                    10,325                    -1,326                    3,327                    6,328                    2,329                    3,330                    -4,331                    -2,332                    9,333                    2,334                    10,335                    4,336                    1,337                    8,338                    2,339                    4,340                    1,341                    3,342                    6,343                    -6,344                    4,345                    1,346                    2,347                    5,348                    3,349                    -1,350                    -4,351                    4,352                    1,353                    10,354                    5,355                    3,356                    7,357                    8,358                    1,359                    -1,360                    6,361                    3,362                    -3,363                    2,364                    5,365                    9,366                    1,367                    4,368                    1,369                    4,370                    5,371                    7,372                    -1,373                    4,374                    2,375                    -2,376                    -8,377                    7,378                    3,379                    7,380                    10,381                    6,382                    4,383                    5,384                    -2,385                    -4,386                    3,387                    -1,388                    3,389                    -5,390                    -1,391                    -7392                ]393            ],394            "output": [395                5,396                6,397                6,398                10,399                10,400                10,401                10,402                10,403                10,404                10,405                10,406                10,407                10,408                10,409                10,410                10,411                10,412                10,413                10,414                10,415                10,416                10,417                10,418                10,419                10,420                10,421                10,422                10,423                10,424                10,425                10,426                15,427                15,428                15,429                15,430                15,431                15,432                15,433                15,434                15,435                15,436                15,437                15,438                15,439                15,440                15,441                15,442                15,443                15,444                15,445                15,446                15,447                15,448                15,449                15,450                15,451                15,452                15,453                15,454                15,455                15,456                15,457                15,458                15,459                15,460                15,461                15,462                15,463                16,464                16,465                16,466                16,467                16,468                16,469                16,470                16,471                16,472                16,473                16,474                16,475                16,476                16,477                16,478                16,479                16,480                16,481                16,482                16,483                16,484                16,485                16,486                16,487                16,488                16,489                16,490                16,491                16,492                16,493                16,494                16495            ]496        },497        {498            "input": [499                [500                    38,501                    17,502                    13,503                    84,504                    13,505                    19,506                    13,507                    41,508                    80,509                    97,510                    3,511                    40,512                    23,513                    8,514                    21,515                    84,516                    44,517                    97,518                    55,519                    54,520                    15,521                    20,522                    28523                ],524                [525                    1,526                    9,527                    4,528                    5,529                    -2,530                    5,531                    5,532                    10,533                    7,534                    1,535                    6,536                    7,537                    1,538                    10,539                    9,540                    -1,541                    1,542                    1,543                    4,544                    8,545                    3,546                    2,547                    5548                ]549            ],550            "output": [551                1,552                9,553                9,554                9,555                9,556                9,557                9,558                10,559                10,560                10,561                10,562                10,563                10,564                10,565                10,566                10,567                10,568                10,569                10,570                10,571                10,572                10,573                10574            ]575        },576        {577            "input": [578                [579                    100,580                    64,581                    69,582                    35,583                    71,584                    51,585                    19,586                    43,587                    56,588                    77,589                    46,590                    72,591                    3,592                    28,593                    68,594                    68,595                    100,596                    44,597                    14,598                    83,599                    86,600                    5,601                    49,602                    16,603                    47,604                    51,605                    36,606                    61,607                    51,608                    72,609                    43,610                    90,611                    94,612                    37,613                    92,614                    53,615                    82,616                    55,617                    60,618                    93,619                    3,620                    52,621                    80,622                    53,623                    25,624                    34,625                    27,626                    54,627                    28,628                    96,629                    89,630                    98,631                    27,632                    53,633                    7,634                    59,635                    89,636                    98,637                    49,638                    87,639                    71,640                    76,641                    52,642                    20,643                    83,644                    50,645                    74,646                    84,647                    77,648                    24,649                    28650                ],651                [652                    2,653                    10,654                    5,655                    3,656                    5,657                    10,658                    8,659                    7,660                    6,661                    1,662                    7,663                    6,664                    5,665                    4,666                    6,667                    1,668                    8,669                    10,670                    1,671                    5,672                    3,673                    6,674                    2,675                    2,676                    8,677                    -6,678                    3,679                    10,680                    7,681                    4,682                    3,683                    4,684                    8,685                    9,686                    4,687                    10,688                    8,689                    9,690                    7,691                    2,692                    -2,693                    7,694                    8,695                    1,696                    8,697                    8,698                    8,699                    9,700                    3,701                    7,702                    10,703                    6,704                    6,705                    10,706                    5,707                    5,708                    -8,709                    -6,710                    -2,711                    3,712                    2,713                    5,714                    2,715                    3,716                    -3,717                    1,718                    9,719                    2,720                    -1,721                    10,722                    -1723                ]724            ],725            "output": [726                2,727                10,728                10,729                10,730                10,731                10,732                10,733                10,734                10,735                10,736                10,737                10,738                10,739                10,740                10,741                10,742                10,743                10,744                10,745                10,746                10,747                10,748                10,749                10,750                10,751                10,752                10,753                10,754                11,755                11,756                11,757                11,758                11,759                11,760                11,761                11,762                11,763                11,764                11,765                11,766                11,767                11,768                11,769                11,770                11,771                11,772                11,773                11,774                11,775                11,776                11,777                11,778                14,779                21,780                21,781                21,782                21,783                21,784                21,785                21,786                21,787                21,788                21,789                21,790                21,791                21,792                21,793                21,794                21,795                21,796                21797            ]798        },799        {800            "input": [801                [802                    54,803                    43,804                    27,805                    82,806                    68,807                    90,808                    84,809                    63,810                    12,811                    96,812                    40,813                    4,814                    96,815                    15,816                    81,817                    93,818                    84,819                    87,820                    43,821                    73,822                    59,823                    83,824                    61,825                    67,826                    53,827                    7,828                    17,829                    72,830                    97,831                    94,832                    6,833                    47,834                    29,835                    92,836                    82,837                    30,838                    23,839                    36,840                    40,841                    62,842                    66,843                    98,844                    54,845                    79,846                    29,847                    89,848                    66,849                    50,850                    94,851                    73,852                    41,853                    5,854                    90,855                    50,856                    92,857                    90,858                    85,859                    85,860                    83,861                    75,862                    65,863                    33,864                    17,865                    7,866                    42,867                    47,868                    83,869                    8,870                    30,871                    71,872                    89,873                    58,874                    81,875                    58,876                    53,877                    59,878                    6,879                    29,880                    20,881                    29,882                    26,883                    71,884                    55,885                    74886                ],887                [888                    2,889                    6,890                    10,891                    3,892                    7,893                    7,894                    10,895                    4,896                    8,897                    3,898                    4,899                    1,900                    -3,901                    9,902                    10,903                    9,904                    9,905                    7,906                    8,907                    7,908                    3,909                    4,910                    4,911                    5,912                    8,913                    7,914                    1,915                    2,916                    8,917                    6,918                    1,919                    2,920                    3,921                    3,922                    -3,923                    7,924                    2,925                    10,926                    9,927                    1,928                    9,929                    8,930                    7,931                    6,932                    7,933                    9,934                    7,935                    8,936                    -5,937                    -7,938                    8,939                    9,940                    -2,941                    9,942                    1,943                    -1,944                    10,945                    -3,946                    3,947                    1,948                    6,949                    7,950                    -1,951                    -5,952                    3,953                    -1,954                    -6,955                    4,956                    -5,957                    9,958                    -9,959                    2,960                    2,961                    8,962                    -3,963                    8,964                    2,965                    1,966                    1,967                    -10,968                    8,969                    -4,970                    9,971                    1972                ]973            ],974            "output": [975                2,976                6,977                10,978                10,979                10,980                10,981                10,982                10,983                10,984                10,985                10,986                10,987                10,988                10,989                10,990                10,991                19,992                19,993                19,994                19,995                19,996                19,997                19,998                19,999                19,1000                19,1001                19,1002                19,1003                19,1004                19,1005                19,1006                19,1007                19,1008                19,1009                19,1010                19,1011                19,1012                19,1013                19,1014                19,1015                19,1016                19,1017                19,1018                19,1019                19,1020                19,1021                19,1022                19,1023                19,1024                19,1025                19,1026                19,1027                19,1028                19,1029                19,1030                19,1031                19,1032                19,1033                19,1034                19,1035                19,1036                19,1037                19,1038                19,1039                19,1040                19,1041                19,1042                19,1043                19,1044                19,1045                19,1046                19,1047                19,1048                19,1049                19,1050                19,1051                19,1052                19,1053                19,1054                19,1055                19,1056                19,1057                19,1058                191059            ]1060        },1061        {1062            "input": [1063                [1064                    46,1065                    94,1066                    90,1067                    23,1068                    20,1069                    54,1070                    45,1071                    51,1072                    63,1073                    97,1074                    13,1075                    57,1076                    8,1077                    19,1078                    82,1079                    85,1080                    36,1081                    78,1082                    87,1083                    12,1084                    3,1085                    2,1086                    36,1087                    40,1088                    61,1089                    16,1090                    55,1091                    60,1092                    44,1093                    701094                ],1095                [1096                    9,1097                    9,1098                    8,1099                    9,1100                    2,1101                    7,1102                    5,1103                    6,1104                    8,1105                    8,1106                    2,1107                    6,1108                    6,1109                    3,1110                    7,1111                    7,1112                    7,1113                    5,1114                    7,1115                    10,1116                    8,1117                    10,1118                    -6,1119                    7,1120                    4,1121                    9,1122                    3,1123                    2,1124                    9,1125                    61126                ]1127            ],1128            "output": [1129                9,1130                9,1131                9,1132                9,1133                9,1134                9,1135                9,1136                9,1137                9,1138                9,1139                9,1140                9,1141                9,1142                9,1143                9,1144                9,1145                9,1146                9,1147                9,1148                10,1149                10,1150                10,1151                10,1152                10,1153                10,1154                10,1155                10,1156                10,1157                10,1158                101159            ]1160        },1161        {1162            "input": [1163                [1164                    55,1165                    99,1166                    53,1167                    91,1168                    88,1169                    72,1170                    55,1171                    77,1172                    391173                ],1174                [1175                    2,1176                    10,1177                    3,1178                    5,1179                    8,1180                    3,1181                    3,1182                    10,1183                    51184                ]1185            ],1186            "output": [1187                2,1188                10,1189                10,1190                10,1191                10,1192                10,1193                10,1194                10,1195                101196            ]1197        },1198        {1199            "input": [1200                [

Showing the first 1,200 of 1699 lines. Download the file for the rest.