Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Working solution for the 2018 AP Computer Science ArrayTester Free Response question
public static int[] getColumn(int[][] arr2D, int c) {
int[] out = new int[arr2D.length];
for (int r=0; r<arr2D.length; r++)
out[r] = arr2D[r][c];
return out;
public static boolean isLatin(int[][] square) {
int[] firstRow = square[0];
if (containsDuplicates(firstRow))
return false;
for (int r=1; r<square.length; r++)
if (!hasAllValues(firstRow, square[r]))
return false;
for (int c=0; c<square[0].length; c++)
if (!hasAllValues(firstRow, getColumn(square, c))
return false;
return true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.