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