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