nirupam.astro
BAN USER- 1of 1 vote
AnswersYou are given an array A with elements 0 to n-1, numbers can be repeated in the array. Create n sets where
- nirupam.astro in India
S[i]={a[i],a[a[i]],a[a[a[i]]]…}. Set has all elements unique. Find the size of the largest set.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer
25a+10b+5c+d=78
find combinations for a=0...3
public static void main(
String[] args) {
String sentence=args[0];
String[] arr = sentence.split(" ");
String abbr;
char first;
char last;
StringBuffer sb =new StringBuffer();
for (String word:arr) {
first=word.charAt(0);
last=word.charAt(word.length()-1);
abbr=first+String.valueOf(word.length()-2)+last;
sb.append(abbr).append(" ");
}
System.out.println(sb);
}
public static Character random(
char[] cha, double[] dba) {
if (cha.length == dba.length) {
List<Character> arr = new ArrayList<>();
int[] inta = new int[cha.length];
for (int i=0;i<inta.length;i++) {
inta[i]=(int) Math.round(dba[i]*100);
}
for (int i=0;i<inta.length;i++)
for (int j = 0; j < inta[i]; j++)
arr.add(cha[i]);
return arr.get((int) Math.round(Math.random()*100));
} else
return null;
}
public static int fibonacci(int n) {
if (n==1 || n==2)
return n;
else
return fibonacci(n-1)+fibonacci(n-2);
}
}
- nirupam.astro December 16, 2013