2024-04-30 10:04:49 +08:00
< p > You are given a 2D boolean matrix < code > grid< / code > .< / p >
2025-01-09 20:29:41 +08:00
< p > A collection of 3 elements of < code > grid< / code > is a < strong > right triangle< / strong > if one of its elements is in the < strong > same row< / strong > with another element and in the < strong > same column< / strong > with the third element. The 3 elements may < strong > not< / strong > be next to each other.< / p >
2024-04-30 10:04:49 +08:00
2025-01-09 20:29:41 +08:00
< p > Return an integer that is the number of < strong > right triangles< / strong > that can be made with 3 elements of < code > grid< / code > such that < strong > all< / strong > of them have a value of 1.< / p >
2024-04-30 10:04:49 +08:00
< p > < / p >
< p > < strong class = "example" > Example 1:< / strong > < / p >
< div style = "display:flex; gap: 12px;" >
< table border = "1" cellspacing = "3" style = "border-collapse: separate; text-align: center;" >
< tbody >
< tr >
2025-01-09 20:29:41 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
2024-04-30 10:04:49 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid red; --darkreader-inline-border-top: #b30000; --darkreader-inline-border-right: #b30000; --darkreader-inline-border-bottom: #b30000; --darkreader-inline-border-left: #b30000;" > 1< / td >
2025-01-09 20:29:41 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
2024-04-30 10:04:49 +08:00
< / tr >
< tr >
2025-01-09 20:29:41 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
2024-04-30 10:04:49 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid red; --darkreader-inline-border-top: #b30000; --darkreader-inline-border-right: #b30000; --darkreader-inline-border-bottom: #b30000; --darkreader-inline-border-left: #b30000;" > 1< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid red; --darkreader-inline-border-top: #b30000; --darkreader-inline-border-right: #b30000; --darkreader-inline-border-bottom: #b30000; --darkreader-inline-border-left: #b30000;" > 1< / td >
< / tr >
< tr >
2025-01-09 20:29:41 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 1< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
2024-04-30 10:04:49 +08:00
< / tr >
< / tbody >
< / table >
< table border = "1" cellspacing = "3" style = "border-collapse: separate; text-align: center;" >
< tbody >
< tr >
2025-01-09 20:29:41 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 1< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
2024-04-30 10:04:49 +08:00
< / tr >
< tr >
2025-01-09 20:29:41 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
2024-04-30 10:04:49 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid red; --darkreader-inline-border-top: #b30000; --darkreader-inline-border-right: #b30000; --darkreader-inline-border-bottom: #b30000; --darkreader-inline-border-left: #b30000;" > 1< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid red; --darkreader-inline-border-top: #b30000; --darkreader-inline-border-right: #b30000; --darkreader-inline-border-bottom: #b30000; --darkreader-inline-border-left: #b30000;" > 1< / td >
< / tr >
< tr >
2025-01-09 20:29:41 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
2024-04-30 10:04:49 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid red; --darkreader-inline-border-top: #b30000; --darkreader-inline-border-right: #b30000; --darkreader-inline-border-bottom: #b30000; --darkreader-inline-border-left: #b30000;" > 1< / td >
2025-01-09 20:29:41 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
< / tr >
< / tbody >
< / table >
< table border = "1" cellspacing = "3" style = "border-collapse: separate; text-align: center;" >
< tbody >
< tr >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid blue; --darkreader-inline-border-top: #b30000; --darkreader-inline-border-right: #b30000; --darkreader-inline-border-bottom: #b30000; --darkreader-inline-border-left: #b30000;" > 1< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
< / tr >
< tr >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid blue; --darkreader-inline-border-top: #b30000; --darkreader-inline-border-right: #b30000; --darkreader-inline-border-bottom: #b30000; --darkreader-inline-border-left: #b30000;" > 1< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #b30000; --darkreader-inline-border-right: #b30000; --darkreader-inline-border-bottom: #b30000; --darkreader-inline-border-left: #b30000;" > 1< / td >
< / tr >
< tr >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid blue; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 1< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
2024-04-30 10:04:49 +08:00
< / tr >
< / tbody >
< / table >
< / div >
< div class = "example-block" >
< p > < strong > Input:< / strong > < span class = "example-io" > grid = [[0,1,0],[0,1,1],[0,1,0]]< / span > < / p >
< p > < strong > Output:< / strong > < span class = "example-io" > 2< / span > < / p >
< p > < strong > Explanation:< / strong > < / p >
2025-01-09 20:29:41 +08:00
< p > There are two right triangles with elements of the value 1. Notice that the blue ones do < strong > not < / strong > form a right triangle because the 3 elements are in the same column.< / p >
2024-04-30 10:04:49 +08:00
< / div >
< p > < strong class = "example" > Example 2:< / strong > < / p >
< div style = "display:flex; gap: 12px;" >
< table border = "1" cellspacing = "3" style = "border-collapse: separate; text-align: center;" >
< tbody >
< tr >
2025-01-09 20:29:41 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid blue; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 1< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
2024-04-30 10:04:49 +08:00
< / tr >
< tr >
2025-01-09 20:29:41 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid blue; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 1< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 1< / td >
2024-04-30 10:04:49 +08:00
< / tr >
< tr >
2025-01-09 20:29:41 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid blue; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 1< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
2024-04-30 10:04:49 +08:00
< / tr >
< / tbody >
< / table >
< / div >
< div class = "example-block" >
< p > < strong > Input:< / strong > < span class = "example-io" > grid = [[1,0,0,0],[0,1,0,1],[1,0,0,0]]< / span > < / p >
< p > < strong > Output:< / strong > < span class = "example-io" > 0< / span > < / p >
< p > < strong > Explanation:< / strong > < / p >
2025-01-09 20:29:41 +08:00
< p > There are no right triangles with elements of the value 1. Notice that the blue ones do < strong > not< / strong > form a right triangle.< / p >
2024-04-30 10:04:49 +08:00
< / div >
< p > < strong class = "example" > Example 3:< / strong > < / p >
< div style = "display:flex; gap: 12px;" >
< table border = "1" cellspacing = "3" style = "border-collapse: separate; text-align: center;" >
< tbody >
< tr >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid red; --darkreader-inline-border-top: #b30000; --darkreader-inline-border-right: #b30000; --darkreader-inline-border-bottom: #b30000; --darkreader-inline-border-left: #b30000;" > 1< / td >
2025-01-09 20:29:41 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
2024-04-30 10:04:49 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid red; --darkreader-inline-border-top: #b30000; --darkreader-inline-border-right: #b30000; --darkreader-inline-border-bottom: #b30000; --darkreader-inline-border-left: #b30000;" > 1< / td >
< / tr >
< tr >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid red; --darkreader-inline-border-top: #b30000; --darkreader-inline-border-right: #b30000; --darkreader-inline-border-bottom: #b30000; --darkreader-inline-border-left: #b30000;" > 1< / td >
2025-01-09 20:29:41 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
2024-04-30 10:04:49 +08:00
< / tr >
< tr >
2025-01-09 20:29:41 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 1< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
2024-04-30 10:04:49 +08:00
< / tr >
< / tbody >
< / table >
< table border = "1" cellspacing = "3" style = "border-collapse: separate; text-align: center;" >
< tbody >
< tr >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid red; --darkreader-inline-border-top: #b30000; --darkreader-inline-border-right: #b30000; --darkreader-inline-border-bottom: #b30000; --darkreader-inline-border-left: #b30000;" > 1< / td >
2025-01-09 20:29:41 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
2024-04-30 10:04:49 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid red; --darkreader-inline-border-top: #b30000; --darkreader-inline-border-right: #b30000; --darkreader-inline-border-bottom: #b30000; --darkreader-inline-border-left: #b30000;" > 1< / td >
< / tr >
< tr >
2025-01-09 20:29:41 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 1< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
2024-04-30 10:04:49 +08:00
< / tr >
< tr >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid red; --darkreader-inline-border-top: #b30000; --darkreader-inline-border-right: #b30000; --darkreader-inline-border-bottom: #b30000; --darkreader-inline-border-left: #b30000;" > 1< / td >
2025-01-09 20:29:41 +08:00
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
< td data-darkreader-inline-border-bottom = "" data-darkreader-inline-border-left = "" data-darkreader-inline-border-right = "" data-darkreader-inline-border-top = "" style = "padding: 5px 10px; border: 1px solid silver; --darkreader-inline-border-top: #8c8273; --darkreader-inline-border-right: #8c8273; --darkreader-inline-border-bottom: #8c8273; --darkreader-inline-border-left: #8c8273;" > 0< / td >
2024-04-30 10:04:49 +08:00
< / tr >
< / tbody >
< / table >
< / div >
< div class = "example-block" >
< p > < strong > Input:< / strong > < span class = "example-io" > grid = [[1,0,1],[1,0,0],[1,0,0]]< / span > < / p >
2025-01-09 20:29:41 +08:00
< p > < strong > Output: < / strong > 2< / p >
2024-04-30 10:04:49 +08:00
< p > < strong > Explanation:< / strong > < / p >
2025-01-09 20:29:41 +08:00
< p > There are two right triangles with elements of the value 1.< / p >
2024-04-30 10:04:49 +08:00
< / div >
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > 1 < = grid.length < = 1000< / code > < / li >
< li > < code > 1 < = grid[i].length < = 1000< / code > < / li >
< li > < code > 0 < = grid[i][j] < = 1< / code > < / li >
< / ul >