Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Function to return whether or not one 'design' array 'fits' into another 'max'

View array_fits_into_another.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
// 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.