Skip to content

Instantly share code, notes, and snippets.

@aajjbb
Created November 22, 2012 01:07
Show Gist options
  • Save aajjbb/4128835 to your computer and use it in GitHub Desktop.
Save aajjbb/4128835 to your computer and use it in GitHub Desktop.
TopCoder SRM 532 DIV 2 250 Solution
import java.util.*;
import java.math.*;
public class DengklekTryingToSleep {
public int minDucks(int[] ducks) {
Arrays.sort(ducks);
Set<Integer> aux = new HashSet<Integer>();
for(int i: ducks) aux.add(i);
int ans = 0;
for(int i = ducks[0] + 1; i <= ducks[ducks.length - 1] - 1; i++) {
if(!aux.contains(i)) ans += 1;
}
return ans;
}
}
// Powered by FileEdit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment