Created
November 22, 2012 01:07
-
-
Save aajjbb/4128835 to your computer and use it in GitHub Desktop.
TopCoder SRM 532 DIV 2 250 Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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