You are viewing a single comment's thread. Return to all comments →
//java public static int gemstones1(List<String> arr) { String common=arr.size()>0?arr.get(0):""; StringBuilder sb=new StringBuilder(); for(int i=1;i<arr.size();i++) { for(int j=0;j<common.length();j++) { if(arr.get(i).indexOf(common.charAt(j))!=-1 && sb.indexOf(String.valueOf(common.charAt(j)))==-1) sb.append(common.charAt(j)); } common=sb.toString(); sb.setLength(0); if(common.length()==0) break; } return common.length(); }
Seems like cookies are disabled on this browser, please enable them to open this website
Gemstones
You are viewing a single comment's thread. Return to all comments →