shobhittandon2003
BAN USERimport java.util.TreeMap;
public class CommonIntegers {
static void commonInt(int[] first,int[] second){
TreeMap<Integer,Integer> map = new TreeMap<Integer,Integer>();
TreeMap<Integer,Integer> answer = new TreeMap<Integer,Integer>();
for(int i:first){
if(map.get(i)==null){
map.put(i, 1);
}
else{
map.put(i, map.get(i)+1);
}
}
for(int i:second){
if(map.get(i)!=null){
answer.put(i, map.get(i)+1);
}
}
System.out.println(answer.keySet());
}
public static void main(String[] args){
int[] A={1,2,3,4,5,6,9} ;
int[] B={5,6,7,8,9} ;
commonInt(A, B);
}
}
public class ReverseStringRecursive {
static String reverseString(String input,int index,String returnString){
if(index<0){
return returnString;
}
else{
returnString =returnString+ input.charAt(index);
input = input.substring(0,index);
index--;
return reverseString(input,index,returnString);
}
}
public static void main(String[] args){
String input = "input string";
String retString ="";
int index = input.length()-1;
System.out.println(reverseString(input,index,retString));
}
}
- shobhittandon2003 August 07, 2014