public class CodeCamp extends Object
| Modifier and Type | Method and Description |
|---|---|
static int |
getValueOfMostValuablePlot(int[][] city)
Given a 2D array of ints return the value of the
most valuable contiguous sub rectangle in the 2D array.
|
static int |
hammingDistance(int[] aList,
int[] bList)
Determine the Hamming distance between two arrays of ints.
|
static boolean |
isPermutation(int[] listA,
int[] listB)
Determine if one array of ints is a permutation of another.
|
static int |
mostVowels(String[] list)
Determine the index of the String that
has the largest number of vowels.
|
static boolean |
queensAreSafe(char[][] board)
Determine if the chess board represented by board is a safe set up.
|
static int |
sharedBirthdays(int numPeople,
int numDaysInYear)
Perform an experiment simulating the birthday problem.
|
public static int hammingDistance(int[] aList,
int[] bList)
aList - != null, aList.length == bList.lengthbList - != null, bList.length == aList.lengthpublic static boolean isPermutation(int[] listA,
int[] listB)
listA - != nulllistB - != nullpublic static int mostVowels(String[] list)
pre: list != null, list.length > 0, there is an least 1 non null element in list
post: return the index of the non-null element in list that has the
largest number of characters that are vowels.
If there is a tie return the index closest to zero.
The empty String, "", has zero vowels.
It is possible for the maximum number of vowels to be 0.
list - the array to checkpublic static int sharedBirthdays(int numPeople,
int numDaysInYear)
numPeople - The number of people in the experiment.
This value must be > 0numDaysInYear - The number of days in the year for this experiement.
This value must be > 0public static boolean queensAreSafe(char[][] board)
pre: board != null, board.length > 0, board is a square matrix.
(In other words all rows in board have board.length columns.),
all elements of board == 'q' or '.'. 'q's represent queens, '.'s
represent open spaces.
post: return true if the configuration of board is safe,
that is no queen can attack any other queen on the board.
false otherwise.
the parameter board is not altered as a result of
this method.
board - the chessboardpublic static int getValueOfMostValuablePlot(int[][] city)
pre: mat != null, mat.length > 0, mat[0].length > 0, mat is a rectangular matrix.
post: return the value of the most valuable contigous sub rectangle
in city.
city - The 2D array of ints representing the value of
each block in a portion of a city.