Skip to content

Instantly share code, notes, and snippets.

@NaotoKumagai
Created December 24, 2016 03:10
Show Gist options
  • Save NaotoKumagai/880e1a83d2663f088ff114ce714c049d to your computer and use it in GitHub Desktop.
Save NaotoKumagai/880e1a83d2663f088ff114ce714c049d to your computer and use it in GitHub Desktop.
Day 14: Scope
// Add your code here
Difference(int[] elements) {
this.elements = elements;
}
public void computeDifference() {
for(int i =0; i< elements.length; i++) {
for(int j=0; j < elements.length; j++) {
int difference = Math.abs(elements[i] - elements[j]);
if(difference > maximumDifference) {
maximumDifference = difference;
}
}
}
}
public int maximumDifference() {
return maximumDifference;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment