You are viewing a single comment's thread. Return to all comments →
I rather used set.
HashSet set = new HashSet<>(); for(int i = 0 ; i < s1.length(); i++){ set.add(s1.charAt(i)); } for(int i = 0 ; i < s2.length(); i++){ if(set.contains(s2.charAt(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 →
I rather used set.
HashSet set = new HashSet<>(); for(int i = 0 ; i < s1.length(); i++){ set.add(s1.charAt(i)); } for(int i = 0 ; i < s2.length(); i++){ if(set.contains(s2.charAt(i))) return "YES"; } return "NO";