CoolFace
Datasetpublic

FPEvalDataset/LeetCodeProblem

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

Showing the first 1,200 of 5114 lines. Download the file for the rest.