You are viewing a single comment's thread. Return to all comments →
static int toInt(String s){ int r = 0; for(char c: s.toCharArray()){ r = r| (1<<(c-'a')); } return r; } static int getBits(int l){ int j=0; for(int i=0; i< 26; i++){ if(((1<<i)&l)!=0){ j++; } } return j; } static int gemstones(String[] arr){ int rs = Integer.MAX_VALUE; for(String s: arr){ rs = rs & toInt(s); } return getBits(rs); }
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 →