
Untitled
By: a guest on
Apr 15th, 2012 | syntax:
None | size: 0.70 KB | hits: 12 | expires: Never
A tool for calculating the big-O time complexity of Java code?
int dcount = 24423567;
int a = 0;
if (dcount == 0){
a = 1;
}
String ds = Integer.toString(dcount);
String[] sa = ds.split("(?<=.)");
HashSet hs = new HashSet();
Collections.addAll(hs, sa);
a = hs.size();
if (dcount < 0)
a--;
System.out.println(a);
int distinctDigits(int num) {
if (num == 0) {
return 1;
}
boolean[] digits = new boolean[10];
while (num > 0) {
digits[num % 10] = true;
num /= 10;
}
int count = 0;
for (boolean digit : digits) {
if (digit) {
count++;
}
}
return count;
}