Created
December 21, 2018 14:57
-
-
Save MMintzer/6520585720c14ae3051c2f36bd361204 to your computer and use it in GitHub Desktop.
river sizes prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RIVER SIZES | |
// You are given a two-dimensiona array (matrix) of potentially unequal height and width containing only 0s and 1s. | |
// Each 0 represents land, and each 1 represents part of a river. A river consists of any number of adjacent 1s forming | |
// a river determine its size. Write a function that returns an array of the sizes of all rivers represented in the input | |
// matrix. Note that these sizes do not need to be in any particular order. | |
Sample input: | |
[ | |
[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,2,2,5] | |
(1 length of 2 river, | |
3 length of 2 rivers, | |
1 length of 5 river) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how can i write in c# code