There was no difficult or unexpected questions. for instance: -sort an array with just two types of elements, optimize your algorithm -find common letters in two strings and put them in a sorted order -compare sorting algorithms
Anonymous
//Find the Common letters in two String and put them in a sorted order public static void commonElements(String s1,String s2) { List list = new ArrayList(); HashMap map1=new HashMap(); HashMap map2=new HashMap(); char[] c1=s1.toCharArray(); char[] c2=s2.toCharArray(); Set set = new HashSet(); for(Character ch1 :c1) { set.add(ch1); map1.put(ch1, (map1.getOrDefault(ch1, 0))+1); } for(Character ch2 :c2) { map2.put(ch2, (map2.getOrDefault(ch2, 0))+1); } for(Character c : set ) { if(map1.containsKey(c)&&map2.containsKey(c)) { int rep=(map1.get(c)<= map2.get(c))?map1.get(c):map2.get(c); for(int i=0;i
Check out your Company Bowl for anonymous work chats.