Skip to content

@notbrain /array_fits_into_another.java
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Function to return whether or not one 'design' array 'fits' into another 'max'
// Currently incomplete implementation!
private Boolean designFits(int[] max, int[] design) {
Boolean designFits = true;
Arrays.sort(max);
Arrays.sort(design);
int passCount = 0;
if(design.length <= max.length) {
for(int i = 0; i < max.length; i++) {
for(int j = 0; j < design.length; j++) {
if(max[i] <= design[j]) {
passCount++;
}
}
}
if(passCount == 0 || passCount > max.length) {
designFits = false;
}
} else {
designFits = false;
}
return designFits;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.