CoolFace
Datasetpublic

TheRealSamuel/LeetCodeProblem

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes561downloads
1{2    "id": 3778,3    "name": "transform_array_by_parity",4    "difficulty": "Easy",5    "link": "https://leetcode.com/problems/transform-array-by-parity/",6    "date": "2025-02-15 00:00:00",7    "task_description": "You are given an integer array `nums`. Transform `nums` by performing the following operations in the **exact** order specified: Replace each even number with 0. Replace each odd numbers with 1. Sort the modified array in **non-decreasing** order. Return the resulting array after performing these operations. **Example 1:** **Input:** nums = [4,3,2,1] **Output:** [0,0,1,1] **Explanation:** Replace the even numbers (4 and 2) with 0 and the odd numbers (3 and 1) with 1. Now, `nums = [0, 1, 0, 1]`. After sorting `nums` in non-descending order, `nums = [0, 0, 1, 1]`. **Example 2:** **Input:** nums = [1,5,1,4,2] **Output:** [0,0,1,1,1] **Explanation:** Replace the even numbers (4 and 2) with 0 and the odd numbers (1, 5 and 1) with 1. Now, `nums = [1, 1, 1, 0, 0]`. After sorting `nums` in non-descending order, `nums = [0, 0, 1, 1, 1]`. **Constraints:** `1 <= nums.length <= 100` `1 <= nums[i] <= 1000`",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "nums = [4,3,2,1]",12            "output": "[0,0,1,1] "13        },14        {15            "label": "Example 2",16            "input": "nums = [1,5,1,4,2]",17            "output": "[0,0,1,1,1] "18        }19    ],20    "private_test_cases": [21        {22            "input": [23                0,24                0,25                0,26                0,27                0,28                0,29                0,30                0,31                0,32                0,33                0,34                0,35                0,36                0,37                0,38                0,39                0,40                0,41                0,42                0,43                0,44                0,45                0,46                0,47                0,48                0,49                0,50                0,51                0,52                0,53                0,54                0,55                0,56                0,57                0,58                0,59                0,60                0,61                0,62                0,63                0,64                0,65                0,66                0,67                0,68                0,69                0,70                0,71                0,72                0,73                1,74                1,75                1,76                1,77                1,78                1,79                1,80                1,81                1,82                1,83                1,84                1,85                1,86                1,87                1,88                1,89                1,90                1,91                1,92                1,93                1,94                1,95                1,96                1,97                1,98                1,99                1,100                1,101                1,102                1,103                1,104                1,105                1,106                1,107                1,108                1,109                1,110                1,111                1,112                1,113                1,114                1,115                1,116                1,117                1,118                1,119                1120            ],121            "output": [122                0,123                0,124                0,125                0,126                0,127                0,128                0,129                0,130                0,131                0,132                0,133                0,134                0,135                0,136                0,137                0,138                0,139                0,140                0,141                0,142                0,143                0,144                0,145                0,146                0,147                0,148                0,149                0,150                0,151                0,152                0,153                0,154                0,155                0,156                0,157                0,158                0,159                0,160                0,161                0,162                0,163                0,164                0,165                0,166                0,167                0,168                0,169                0,170                0,171                0,172                1,173                1,174                1,175                1,176                1,177                1,178                1,179                1,180                1,181                1,182                1,183                1,184                1,185                1,186                1,187                1,188                1,189                1,190                1,191                1,192                1,193                1,194                1,195                1,196                1,197                1,198                1,199                1,200                1,201                1,202                1,203                1,204                1,205                1,206                1,207                1,208                1,209                1,210                1,211                1,212                1,213                1,214                1,215                1,216                1,217                1,218                1219            ]220        },221        {222            "input": [223                0,224                0,225                0,226                0,227                0,228                0,229                0,230                0,231                0,232                0,233                0,234                0,235                0,236                1,237                1,238                1,239                1,240                1,241                1,242                1,243                1,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                1259            ],260            "output": [261                0,262                0,263                0,264                0,265                0,266                0,267                0,268                0,269                0,270                0,271                0,272                0,273                0,274                1,275                1,276                1,277                1,278                1,279                1,280                1,281                1,282                1,283                1,284                1,285                1,286                1,287                1,288                1,289                1,290                1,291                1,292                1,293                1,294                1,295                1,296                1297            ]298        },299        {300            "input": [301                0,302                0,303                0,304                0,305                0,306                0,307                0,308                0,309                0,310                0,311                0,312                0,313                0,314                0,315                0,316                0,317                0,318                0,319                0,320                0,321                0,322                0,323                0,324                0,325                0,326                0,327                0,328                0,329                0,330                0,331                0,332                0,333                0,334                0,335                0,336                0,337                0,338                0,339                0,340                0,341                0,342                0,343                0,344                1,345                1,346                1,347                1,348                1,349                1,350                1,351                1,352                1,353                1,354                1,355                1,356                1,357                1,358                1,359                1,360                1,361                1,362                1,363                1,364                1,365                1,366                1,367                1,368                1,369                1,370                1,371                1,372                1,373                1,374                1,375                1,376                1,377                1,378                1,379                1,380                1,381                1,382                1,383                1,384                1,385                1,386                1,387                1,388                1,389                1390            ],391            "output": [392                0,393                0,394                0,395                0,396                0,397                0,398                0,399                0,400                0,401                0,402                0,403                0,404                0,405                0,406                0,407                0,408                0,409                0,410                0,411                0,412                0,413                0,414                0,415                0,416                0,417                0,418                0,419                0,420                0,421                0,422                0,423                0,424                0,425                0,426                0,427                0,428                0,429                0,430                0,431                0,432                0,433                0,434                0,435                1,436                1,437                1,438                1,439                1,440                1,441                1,442                1,443                1,444                1,445                1,446                1,447                1,448                1,449                1,450                1,451                1,452                1,453                1,454                1,455                1,456                1,457                1,458                1,459                1,460                1,461                1,462                1,463                1,464                1,465                1,466                1,467                1,468                1,469                1,470                1,471                1,472                1,473                1,474                1,475                1,476                1,477                1,478                1,479                1,480                1481            ]482        },483        {484            "input": [485                0,486                0,487                0,488                0,489                0,490                0,491                0,492                0,493                1,494                1,495                1,496                1497            ],498            "output": [499                0,500                0,501                0,502                0,503                0,504                0,505                0,506                0,507                1,508                1,509                1,510                1511            ]512        },513        {514            "input": [515                0,516                0,517                0,518                0,519                0,520                0,521                0,522                0,523                0,524                0,525                0,526                0,527                0,528                0,529                0,530                0,531                0,532                0,533                0,534                0,535                0,536                0,537                0,538                0,539                0,540                0,541                0,542                0,543                0,544                0,545                0,546                0,547                0,548                0,549                0,550                0,551                1,552                1,553                1,554                1,555                1,556                1,557                1,558                1,559                1,560                1,561                1,562                1,563                1,564                1,565                1,566                1,567                1,568                1,569                1,570                1,571                1,572                1,573                1,574                1,575                1,576                1,577                1,578                1,579                1,580                1581            ],582            "output": [583                0,584                0,585                0,586                0,587                0,588                0,589                0,590                0,591                0,592                0,593                0,594                0,595                0,596                0,597                0,598                0,599                0,600                0,601                0,602                0,603                0,604                0,605                0,606                0,607                0,608                0,609                0,610                0,611                0,612                0,613                0,614                0,615                0,616                0,617                0,618                0,619                1,620                1,621                1,622                1,623                1,624                1,625                1,626                1,627                1,628                1,629                1,630                1,631                1,632                1,633                1,634                1,635                1,636                1,637                1,638                1,639                1,640                1,641                1,642                1,643                1,644                1,645                1,646                1,647                1,648                1649            ]650        }651    ],652    "haskell_template": "transformArray :: [Int] -> [Int]\ntransformArray nums ",653    "ocaml_template": "let transformArray (nums: int list) : int list =  ",654    "scala_template": "def transformArray(nums: List[Int]): List[Int] = { \n    \n}",655    "java_template": "class Solution {\n    public int[] transformArray(int[] nums) {\n        \n    }\n}",656    "python_template": "class Solution(object):\n    def transformArray(self, nums):\n        \"\"\"\n        :type nums: List[int]\n        :rtype: List[int]\n        \"\"\"\n        "657}