It will be written in c# code Q 2: River Lengths It gives you two potentially unequal height and width, containing only

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

It will be written in c# code Q 2: River Lengths It gives you two potentially unequal height and width, containing only

Post by answerhappygod »

It will be written in c# code
Q 2: River Lengths
It gives you two potentially unequal height and width, containing
only 0's and 1's.
A dimensional array (matrix) is given. Each 0 represents land and
each 1 represents a section of a river.
A river is any number of horizontally or vertically adjacent (but
not diagonally adjacent)
It consists of 1. The number of adjacent 1s that make up a river
determines its size.
Remember that a river can bend. In other words, a straight vertical
line or a straight horizontal line.
it doesn't have to be; For example, it can be L-shaped.
Write a method that returns an array of the sizes of all rivers
represented in the input matrix.
The dimensions do not have to be in any particular order.
Example Input
matrix = [
[1, 0, 0, 1, 0],
[1, 0, 1, 0, 0],
[0, 0, 1, 0, 1],
[1, 0, 1, 0, 1],
[1, 0, 1, 1, 0],
]
Sample Output
[1, 2, 5] // Numbers can be sorted differently.
public static List<int> RiverLengths(int[,] matrix) {
// Write your code here.
return new List<int>();
}
we call different color
It Will Be Written In C Code Q 2 River Lengths It Gives You Two Potentially Unequal Height And Width Containing Only 1
It Will Be Written In C Code Q 2 River Lengths It Gives You Two Potentially Unequal Height And Width Containing Only 1 (7.09 KiB) Viewed 34 times
Örnek Girdi matrix = 1 (1, 0, 0, 1, 0], (1, 0, 1, 0, 0], [0, 0, 1, 0, 1), (1, 0, 1, 0, 1), (1, 0, 1, 1,0], ]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply