CoolFace
Datasetpublic

TheRealSamuel/LeetCodeProblem

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes564downloads
1{2    "id": 2319,3    "name": "longest_substring_of_one_repeating_character",4    "difficulty": "Hard",5    "link": "https://leetcode.com/problems/longest-substring-of-one-repeating-character/",6    "date": "1647129600000",7    "task_description": "You are given a **0-indexed** string `s`. You are also given a **0-indexed** string `queryCharacters` of length `k` and a **0-indexed** array of integer **indices** `queryIndices` of length `k`, both of which are used to describe `k` queries. The `ith` query updates the character in `s` at index `queryIndices[i]` to the character `queryCharacters[i]`. Return _an array_ `lengths` _of length _`k`_ where_ `lengths[i]` _is the **length** of the **longest substring** of _`s`_ consisting of **only one repeating** character **after** the_ `ith` _query__ is performed._ **Example 1:** ``` **Input:** s = \"babacc\", queryCharacters = \"bcb\", queryIndices = [1,3,3] **Output:** [3,3,4] **Explanation:** - 1st query updates s = \"b**b**bacc\". The longest substring consisting of one repeating character is \"bbb\" with length 3. - 2nd query updates s = \"bbb**c**cc\". The longest substring consisting of one repeating character can be \"bbb\" or \"ccc\" with length 3. - 3rd query updates s = \"bbb**b**cc\". The longest substring consisting of one repeating character is \"bbbb\" with length 4. Thus, we return [3,3,4]. ``` **Example 2:** ``` **Input:** s = \"abyzz\", queryCharacters = \"aa\", queryIndices = [2,1] **Output:** [2,3] **Explanation:** - 1st query updates s = \"ab**a**zz\". The longest substring consisting of one repeating character is \"zz\" with length 2. - 2nd query updates s = \"a**a**azz\". The longest substring consisting of one repeating character is \"aaa\" with length 3. Thus, we return [2,3]. ``` **Constraints:** `1 <= s.length <= 105` `s` consists of lowercase English letters. `k == queryCharacters.length == queryIndices.length` `1 <= k <= 105` `queryCharacters` consists of lowercase English letters. `0 <= queryIndices[i] < s.length`",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "s = \"babacc\", queryCharacters = \"bcb\", queryIndices = [1,3,3]",12            "output": "[3,3,4] "13        },14        {15            "label": "Example 2",16            "input": "s = \"abyzz\", queryCharacters = \"aa\", queryIndices = [2,1]",17            "output": "[2,3] "18        }19    ],20    "private_test_cases": [21        {22            "input": [23                "\"mldyufrhyddnbawxkxeft\"",24                "\"hhfqjppcruhikachwlabsdhjzfyyxpstnhazmpe\"",25                [26                    16,27                    14,28                    14,29                    8,30                    14,31                    13,32                    17,33                    3,34                    20,35                    10,36                    18,37                    18,38                    20,39                    9,40                    3,41                    12,42                    14,43                    20,44                    8,45                    17,46                    2,47                    15,48                    5,49                    8,50                    13,51                    8,52                    6,53                    3,54                    9,55                    15,56                    4,57                    4,58                    17,59                    13,60                    7,61                    6,62                    0,63                    15,64                    1165                ]66            ],67            "output": [68                2,69                2,70                2,71                2,72                2,73                2,74                2,75                2,76                2,77                1,78                1,79                1,80                1,81                1,82                1,83                1,84                1,85                1,86                2,87                2,88                2,89                2,90                2,91                1,92                1,93                1,94                1,95                1,96                1,97                1,98                1,99                1,100                1,101                2,102                2,103                2,104                2,105                2,106                2107            ]108        },109        {110            "input": [111                "\"yqhpdmefhzuujqtttgctyhaajxomcwyhkdkpnmxmfeqvjeudkpumdjyrqymdgspvsqlzfjtijwdffrhgyjpygacmkv\"",112                "\"aa\"",113                [114                    26,115                    5116                ]117            ],118            "output": [119                3,120                3121            ]122        },123        {124            "input": [125                "\"fwisuvqxrdpqmomunucphecqlvphsaxcjstsuqqxv\"",126                "\"ophvjfqirvbjalbqkpaozlvewmvmnhbjwotsphkdygveczwxqxmoffruachbrmzfihqluzhrlssqffalo\"",127                [128                    25,129                    1,130                    5,131                    36,132                    2,133                    1,134                    15,135                    38,136                    27,137                    14,138                    0,139                    28,140                    20,141                    28,142                    32,143                    0,144                    11,145                    15,146                    30,147                    11,148                    7,149                    28,150                    1,151                    15,152                    6,153                    13,154                    7,155                    11,156                    21,157                    2,158                    29,159                    6,160                    12,161                    3,162                    1,163                    20,164                    10,165                    20,166                    4,167                    15,168                    6,169                    10,170                    24,171                    19,172                    12,173                    16,174                    9,175                    29,176                    27,177                    27,178                    7,179                    35,180                    17,181                    10,182                    25,183                    30,184                    13,185                    20,186                    27,187                    39,188                    38,189                    8,190                    11,191                    36,192                    35,193                    31,194                    3,195                    20,196                    22,197                    37,198                    36,199                    38,200                    8,201                    35,202                    7,203                    23,204                    40,205                    9,206                    36,207                    18,208                    5209                ]210            ],211            "output": [212                2,213                2,214                2,215                2,216                2,217                2,218                2,219                2,220                2,221                2,222                1,223                1,224                1,225                1,226                1,227                1,228                1,229                1,230                2,231                2,232                2,233                2,234                2,235                2,236                2,237                2,238                2,239                3,240                3,241                3,242                3,243                3,244                1,245                1,246                1,247                1,248                1,249                1,250                1,251                1,252                1,253                1,254                1,255                1,256                1,257                1,258                1,259                1,260                1,261                1,262                1,263                1,264                1,265                1,266                1,267                1,268                1,269                1,270                1,271                1,272                1,273                2,274                2,275                2,276                2,277                2,278                2,279                2,280                2,281                2,282                2,283                2,284                1,285                1,286                1,287                1,288                1,289                2,290                2,291                2,292                2293            ]294        },295        {296            "input": [297                "\"pbxsrqesvrauzwfqlgtnkfdgutaldupodjatkgfvkglnyczslirgsoa\"",298                "\"occchvbilygtciuzjxyzwepvcvlllrnytsykqizpmozdlqqywharlrapfpzndbj\"",299                [300                    1,301                    47,302                    10,303                    38,304                    42,305                    6,306                    10,307                    37,308                    27,309                    22,310                    22,311                    24,312                    39,313                    36,314                    2,315                    23,316                    14,317                    9,318                    32,319                    5,320                    17,321                    3,322                    29,323                    44,324                    51,325                    24,326                    50,327                    39,328                    45,329                    37,330                    47,331                    46,332                    38,333                    51,334                    12,335                    49,336                    42,337                    16,338                    41,339                    11,340                    46,341                    31,342                    2,343                    11,344                    27,345                    2,346                    29,347                    24,348                    52,349                    52,350                    45,351                    40,352                    52,353                    13,354                    12,355                    39,356                    19,357                    0,358                    29,359                    13,360                    35,361                    11,362                    9363                ]364            ],365            "output": [366                1,367                1,368                1,369                1,370                1,371                1,372                1,373                1,374                1,375                1,376                2,377                2,378                2,379                2,380                2,381                2,382                2,383                2,384                2,385                2,386                2,387                2,388                2,389                2,390                2,391                2,392                2,393                2,394                2,395                2,396                2,397                2,398                2,399                2,400                2,401                2,402                2,403                2,404                2,405                2,406                2,407                2,408                2,409                2,410                2,411                2,412                2,413                2,414                1,415                1,416                1,417                1,418                1,419                1,420                1,421                1,422                1,423                1,424                1,425                1,426                1,427                2,428                2429            ]430        },431        {432            "input": [433                "\"dxttasnzkkybjnvuevkxeobdbiudldvaonmqjaxhnbzqlvuijmzbfs\"",434                "\"wbddpbsy\"",435                [436                    46,437                    19,438                    19,439                    33,440                    14,441                    25,442                    51,443                    43444                ]445            ],446            "output": [447                2,448                2,449                2,450                2,451                2,452                2,453                2,454                2455            ]456        },457        {458            "input": [459                "\"jhlruycytwwhfbbgvqdnyykzlfcvizzecbkcdnjrhilacnnkhwewcrlpyht\"",460                "\"bjoohpjxyakjz\"",461                [462                    10,463                    40,464                    40,465                    25,466                    43,467                    29,468                    54,469                    19,470                    6,471                    53,472                    27,473                    28,474                    44475                ]476            ],477            "output": [478                2,479                2,480                2,481                2,482                2,483                2,484                2,485                2,486                3,487                3,488                3,489                3,490                3491            ]492        },493        {494            "input": [495                "\"mjnuuayckgg\"",496                "\"dgbhoanwizjgleuoagvjaok\"",497                [498                    8,499                    7,500                    0,501                    9,502                    9,503                    5,504                    10,505                    2,506                    10,507                    1,508                    8,509                    10,510                    10,511                    1,512                    9,513                    1,514                    5,515                    1,516                    7,517                    8,518                    7,519                    7,520                    4521                ]522            ],523            "output": [524                2,525                2,526                2,527                2,528                2,529                2,530                2,531                2,532                2,533                2,534                2,535                2,536                2,537                2,538                2,539                2,540                2,541                2,542                2,543                2,544                2,545                2,546                1547            ]548        },549        {550            "input": [551                "wtxtjwomvzrnojdcitibpsodcymjpzdunhavgkjsnzxwljkxmorcuuivhpifqnpytspdybhbedihgyuc",552                "kxuuncqkmxbtgiuwgpniflxrbfdzacyzlsvjclwiqdgkupwqcjnjisuzrofpqoxvcbjgkekktxonfyafuwjhix",553                [554                    58,555                    22,556                    79,557                    16,558                    4,559                    76,560                    7,561                    72,562                    67,563                    26,564                    63,565                    24,566                    26,567                    30,568                    54,569                    29,570                    12,571                    74,572                    79,573                    38,574                    68,575                    26,576                    3,577                    43,578                    24,579                    43,580                    67,581                    8,582                    24,583                    5,584                    66,585                    66,586                    62,587                    71,588                    25,589                    69,590                    40,591                    22,592                    61,593                    18,594                    39,595                    29,596                    10,597                    58,598                    36,599                    8,600                    19,601                    13,602                    11,603                    50,604                    31,605                    31,606                    19,607                    43,608                    72,609                    39,610                    33,611                    77,612                    16,613                    72,614                    65,615                    64,616                    28,617                    34,618                    11,619                    66,620                    61,621                    9,622                    16,623                    79,624                    13,625                    76,626                    51,627                    25,628                    10,629                    6,630                    37,631                    10,632                    63,633                    55,634                    55,635                    75,636                    78,637                    43,638                    27,639                    44640                ]641            ],642            "output": [643                2,644                2,645                2,646                2,647                2,648                2,649                2,650                2,651                2,652                2,653                2,654                2,655                2,656                2,657                3,658                3,659                3,660                3,661                3,662                3,663                3,664                3,665                3,666                3,667                3,668                3,669                3,670                3,671                3,672                3,673                3,674                3,675                3,676                3,677                3,678                3,679                3,680                3,681                3,682                3,683                3,684                3,685                3,686                3,687                3,688                3,689                3,690                3,691                3,692                3,693                3,694                3,695                3,696                3,697                3,698                3,699                3,700                3,701                3,702                3,703                3,704                3,705                3,706                3,707                3,708                3,709                3,710                3,711                3,712                3,713                3,714                3,715                3,716                3,717                3,718                3,719                3,720                3,721                3,722                3,723                4,724                4,725                4,726                4,727                4,728                4729            ]730        },731        {732            "input": [733                "wqunykjfmqseeq",734                "uocqonbcyfxzmafouqdvbrkjgwjxhvvdpxjtexjtrxdwwyinifh",735                [736                    4,737                    0,738                    12,739                    7,740                    10,741                    12,742                    10,743                    4,744                    10,745                    0,746                    6,747                    2,748                    11,749                    6,750                    13,751                    11,752                    9,753                    5,754                    2,755                    3,756                    6,757                    11,758                    10,759                    1,760                    8,761                    13,762                    11,763                    13,764                    8,765                    5,766                    12,767                    13,768                    7,769                    8,770                    3,771                    9,772                    7,773                    3,774                    11,775                    4,776                    0,777                    4,778                    7,779                    13,780                    1,781                    13,782                    10,783                    5,784                    11,785                    9,786                    0787                ]788            ],789            "output": [790                2,791                2,792                1,793                1,794                1,795                1,796                1,797                1,798                1,799                1,800                1,801                1,802                1,803                1,804                1,805                1,806                1,807                1,808                1,809                1,810                1,811                1,812                1,813                1,814                1,815                1,816                1,817                1,818                1,819                1,820                1,821                1,822                1,823                1,824                1,825                1,826                1,827                1,828                1,829                1,830                1,831                2,832                2,833                2,834                2,835                2,836                2,837                2,838                2,839                2,840                2841            ]842        },843        {844            "input": [845                "ehkwhiiiltfqspihjbqcjljvicnahjcc",846                "tumrciabnkakulboptzvlbtrwfwjcuesvtgkzgecixhhnjukbdsvjasbnydzdabvajvuxiehhrftlsrrwmafxajgksrrkk",847                [848                    18,849                    11,850                    21,851                    3,852                    17,853                    17,854                    14,855                    31,856                    30,857                    9,858                    25,859                    17,860                    21,861                    20,862                    14,863                    21,864                    11,865                    9,866                    9,867                    8,868                    30,869                    23,870                    20,871                    7,872                    18,873                    14,874                    24,875                    8,876                    8,877                    22,878                    5,879                    21,880                    4,881                    13,882                    22,883                    3,884                    8,885                    16,886                    28,887                    6,888                    25,889                    11,890                    3,891                    26,892                    11,893                    20,894                    18,895                    15,896                    20,897                    31,898                    19,899                    11,900                    28,901                    5,902                    21,903                    4,904                    21,905                    15,906                    20,907                    8,908                    8,909                    13,910                    31,911                    14,912                    23,913                    19,914                    9,915                    27,916                    30,917                    4,918                    30,919                    11,920                    21,921                    25,922                    19,923                    17,924                    20,925                    1,926                    23,927                    18,928                    26,929                    4,930                    17,931                    17,932                    16,933                    2,934                    19,935                    4,936                    1,937                    4,938                    9,939                    29,940                    4,941                    15942                ]943            ],944            "output": [945                3,946                3,947                3,948                3,949                3,950                3,951                3,952                3,953                3,954                3,955                3,956                3,957                3,958                3,959                3,960                3,961                3,962                3,963                3,964                3,965                3,966                3,967                3,968                2,969                2,970                2,971                2,972                2,973                2,974                2,975                1,976                1,977                1,978                1,979                1,980                2,981                2,982                2,983                2,984                2,985                2,986                2,987                2,988                2,989                2,990                2,991                2,992                2,993                2,994                2,995                2,996                2,997                2,998                2,999                2,1000                2,1001                2,1002                2,1003                2,1004                2,1005                2,1006                2,1007                2,1008                2,1009                2,1010                2,1011                2,1012                2,1013                2,1014                2,1015                2,1016                2,1017                2,1018                2,1019                2,1020                2,1021                2,1022                2,1023                2,1024                2,1025                2,1026                2,1027                2,1028                2,1029                2,1030                2,1031                2,1032                2,1033                2,1034                2,1035                2,1036                1,1037                1,1038                11039            ]1040        }1041    ],1042    "haskell_template": "longestRepeating :: String -> String -> [Int] -> [Int]\nlongestRepeating s queryCharacters queryIndices ",1043    "ocaml_template": "let longestRepeating (s: string) (queryCharacters: string) (queryIndices: int list) : int list =  ",1044    "scala_template": "def longestRepeating(s: String,queryCharacters: String,queryIndices: List[Int]): List[Int] = { \n    \n}",1045    "java_template": "public static List<Integer> longestRepeating(String s, String queryCharacters, List<Integer> queryIndices) {\n\n}",1046    "python_template": "class Solution(object):\n    def longestRepeating(self, s, queryCharacters, queryIndices):\n        \"\"\"\n        :type s: str\n        :type queryCharacters: str\n        :type queryIndices: List[int]\n        :rtype: List[int]\n        \"\"\"\n        "1047}