Say, if I have a 2D array:
int[][] s = {{1, 4, 5, 10, 11}, {2, 6, 8}, {3, 9, 12}, {7}};
and I want to write a method that makes sure the next row has a shorter length than the rest of the array how would I go about doing so?
Basically how would I write a method that returns true if no row is longer than a preceding row, and false otherwise?
Here is my logic even though I'm far off, just don't understand logically how to go about it I guess.
public static boolean rowDecrease(int[][] t){
//result empty array here
for (int j = 0; j < t.length; j++) {
for (int i = 0; i< t[i].length; i++) { // Sum of Columns
if (t[i].length>result){
result = t[i].length;
return false;
}
if (t[i].length<result){
result = t[i].length;
return true;
}
}
}