In the program, you need to declare a two-dimensional array and find a row or column in which some element is repeated as often as possible.
Example:
0 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 Answer: 3rd line.
How could this algorithm be described? I can not think of a skeleton for the code.
For example, I started writing code:
public static void main(String[] args) { int SIZE = 3, a = 0; int[][] graph = new int[SIZE][SIZE]; for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { graph[i][j] = i+1; i = j+1; } } for (int i = 0; i < graph.length; i++) { for (int j = 0; j < graph[i].length; j++) { System.out.print(graph[i][j] +"\t"); } System.out.println(); } for (int i = 0; i < graph.length; i++) { for (int j = 0; j < graph[i].length; j++) { if(graph[i][j] == graph[i+1][j+1]){ a = a + 1; } } }