You are viewing a single comment's thread. Return to all comments →
Set<Character> set1=new TreeSet<>(); Set<Character> set2=new TreeSet<>(); for(char c : s1.toCharArray()){ set1.add(c); } for(char c : s2.toCharArray()){ set2.add(c); } List<Character> ch1=new ArrayList<>(set1); List<Character> ch2=new ArrayList<>(set2); System.out.println(ch1); for(int i=0;i<ch1.size();i++){ if(ch2.contains(ch1.get(i))){ return "YES"; } } return "NO";
Seems like cookies are disabled on this browser, please enable them to open this website
Two Strings
You are viewing a single comment's thread. Return to all comments →
Java