id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

tlsmith2@wsfcs.k12.nc.us > array2DColumnMins
prev  |  next  |  chance

Return an integer 1D array that contains the minimum value from each column. The 2D array nums will not be empty.

Important Note: Copy the following two methods into the window and don't change 
array2DColumnMins.  CodingBat does not allow 2D array parameters, so this method is accepting 
the number of rows, number of columns, and a 1D array.  The first method takes this 
information and creates a 2D array named nums that you will be using. Enter your code into 
method array2DColumnMinsB:

public int[] array2DColumnMins(int rows, int cols, int[] array)
{
	int[][] array2D = new int[rows][cols];
	int idx = 0;
	for (int r=0; r<rows; r++)
	{
		for (int c=0; c<cols; c++)
		{
			array2D[r][c] = array[idx];
			idx++;
		}
	}
	return array2DColumnMinsB(array2D);
}

public int[] array2DColumnMinsB(int[][] nums) { 

}

array2DColumnMins(3, 3, [50, 100, 30, 20, 60, 70, 80, 90, 40]) → [20, 60, 30]
array2DColumnMins(3, 2, [50, 100, 30, 90, 60, 70]) → [30, 70]
array2DColumnMins(2, 2, [50, 60, 50, 60]) → [50, 60]

...Save, Compile, Run (ctrl-enter)

public int[] array2DColumnMins(int rows, int cols, int[] array) }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 10 Post-solution available

Copyright Nick Parlante 2017 - privacy