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