+ 3
How to write a java program for finding square submatrix with highest sum value from matrix of variable dimension?
Consider a 2D matrix of numbers from 0 to 9 with variable width and height. Find the square submatrix with the highest sum of boundary elements.
17 ответов
0
I did it in university, does the square have pre-defined size or can it be in any size
0
not defined value is given for square submatrix .bt here we can take of size 3×3.
0
Okay, so what you want is
01 02 03 04 05
06 07 08 09 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
And find the square with the
biggest sum of boundaries?
0
Which is
13 14 15
18 19 20
23 24 25
0
yes..this is the right output.bt how to write java code for this.im not getting the logic for this.
0
Right, so basically the center of the square doesn't matter, only the boundaries?
0
yeah..bt sum value of matrix must be high as compare to other submatrix.
0
I gave it as an example, obviously it's not sorted
0
Mubasshira Khan but are all the numbers in the matrix are to sum or only the boundaries?
0
not necessary that all the elements in matrix need to be sorted...and have to find sum of all values including center value of a square submatrix.
0
Okay, I'll answer when I'll get to a computer because it's impossible through phone
0
He said 2D
0
Also multiple dimensions can be 10D as well, it's two-dimensional array, not multiple.
0
No one calls it multidimensional sir, that's why.
0
its a 2D array..nd we have to derive a square submatrix from this 2D matrix.
0
Eldar Bakerman sir can you share a code for this problem if you have solved?
0
I did not have time.
Anyway what you need to do is 2 for loops and a check of how can you form a square.