CoolFace
Datasetpublic

TheRealSamuel/LeetCodeProblem

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes564downloads
1{2    "id": 3463,3    "name": "alternating_groups_i",4    "difficulty": "Easy",5    "link": "https://leetcode.com/problems/alternating-groups-i/",6    "date": "2024-06-22 00:00:00",7    "task_description": "There is a circle of red and blue tiles. You are given an array of integers `colors`. The color of tile `i` is represented by `colors[i]`: `colors[i] == 0` means that tile `i` is **red**. `colors[i] == 1` means that tile `i` is **blue**. Every 3 contiguous tiles in the circle with **alternating** colors (the middle tile has a different color from its **left** and **right** tiles) is called an **alternating** group. Return the number of **alternating** groups. **Note** that since `colors` represents a **circle**, the **first** and the **last** tiles are considered to be next to each other. **Example 1:** **Input:** colors = [1,1,1] **Output:** 0 **Explanation:** **Example 2:** **Input:** colors = [0,1,0,0,1] **Output:** 3 **Explanation:** Alternating groups: ******** **Constraints:** `3 <= colors.length <= 100` `0 <= colors[i] <= 1`",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "colors = [1,1,1]",12            "output": "0 "13        },14        {15            "label": "Example 2",16            "input": "colors = [0,1,0,0,1]",17            "output": "3 "18        }19    ],20    "private_test_cases": [21        {22            "input": [23                1,24                0,25                1,26                1,27                0,28                0,29                0,30                1,31                1,32                0,33                0,34                1,35                0,36                1,37                0,38                0,39                1,40                1,41                0,42                0,43                1,44                0,45                0,46                0,47                0,48                0,49                1,50                0,51                1,52                0,53                1,54                0,55                056            ],57            "output": 1158        },59        {60            "input": [61                0,62                1,63                0,64                1,65                1,66                1,67                1,68                1,69                1,70                1,71                0,72                0,73                0,74                1,75                1,76                1,77                1,78                1,79                1,80                1,81                0,82                1,83                0,84                0,85                1,86                0,87                1,88                0,89                0,90                1,91                1,92                0,93                1,94                0,95                0,96                0,97                0,98                0,99                1,100                0,101                1,102                0,103                0,104                1,105                0,106                0,107                1,108                1,109                1,110                1,111                0,112                1,113                0,114                1,115                0,116                0,117                0,118                1,119                0,120                0,121                1,122                1,123                1,124                1,125                1,126                1,127                0,128                1,129                1,130                1,131                0,132                1,133                1,134                1,135                1,136                1,137                1,138                1,139                0,140                1,141                0,142                1,143                0,144                1,145                1,146                1,147                0,148                1,149                0,150                1,151                1,152                1,153                1,154                0,155                1,156                1157            ],158            "output": 30159        },160        {161            "input": [162                1,163                0,164                0,165                0,166                0,167                0,168                1,169                0,170                1,171                0,172                1,173                1,174                0,175                0,176                0,177                0,178                1,179                1,180                1,181                0,182                0,183                1,184                0,185                0,186                1,187                1,188                0,189                0,190                1,191                1192            ],193            "output": 5194        },195        {196            "input": [197                1,198                1,199                0,200                0,201                1,202                0,203                1,204                0,205                0,206                1,207                0,208                0,209                1,210                1,211                1,212                1,213                0,214                1,215                1,216                0,217                1,218                1,219                0,220                1,221                1,222                1,223                0,224                1,225                0,226                0,227                1,228                0,229                1,230                1,231                0,232                0,233                1,234                0,235                1,236                0,237                1,238                1,239                1,240                1,241                1,242                0,243                0,244                1,245                0,246                1,247                1,248                0,249                0,250                0,251                0,252                0,253                1,254                1,255                1,256                0,257                0,258                1,259                0,260                0,261                1,262                1,263                1,264                0265            ],266            "output": 19267        },268        {269            "input": [270                0,271                1,272                0,273                0,274                1,275                1,276                1,277                1,278                0,279                1,280                0,281                1,282                1,283                1,284                0,285                0,286                1,287                0,288                0,289                0,290                1,291                1,292                0,293                1,294                0,295                0,296                1,297                1,298                1,299                1,300                1,301                1,302                0,303                1,304                1,305                0,306                0,307                0,308                1,309                1,310                0,311                1,312                0,313                0,314                0,315                0,316                1,317                1,318                0,319                0,320                0,321                0,322                1,323                0324            ],325            "output": 11326        }327    ],328    "haskell_template": "numberOfAlternatingGroups :: [Int] -> Int\nnumberOfAlternatingGroups colors ",329    "ocaml_template": "let numberOfAlternatingGroups (colors: int list) : int =  ",330    "scala_template": "def numberOfAlternatingGroups(colors: List[Int]): Int = { \n    \n}",331    "java_template": "class Solution {\n    public int numberOfAlternatingGroups(int[] colors) {\n        \n    }\n}",332    "python_template": "class Solution(object):\n    def numberOfAlternatingGroups(self, colors):\n        \"\"\"\n        :type colors: List[int]\n        :rtype: int\n        \"\"\"\n        "333}