Sort by

recency

|

2298 Discussions

|

  • + 0 comments

    Two Strings is a small music studio where creativity and rhythm come together in the most unexpected ways. Just like a melody, life sometimes needs balance and harmony, which reminds me of how important it is to take care of daily routines, even dental health. Visiting a trusted Dentist in Marysville https://smilemarysville.com/ ensures that a bright smile stays healthy while pursuing passions and hobbies. Every note played on a guitar string or piano key reflects patience and attention, similar to maintaining personal wellness. Music and self-care both require consistency and a gentle touch. Stopping by a Dentist in Marysville becomes part of a healthy lifestyle that complements all other activities.

  • + 0 comments

    My minimaist O(n + m) solution:

        public static String twoStrings(String s1, String s2) {
        boolean[] s1_array = new boolean[26];
        int base = (int)'a';
        
        for (int i = 0 ; i < s1.length() ; i++){
            int position = (int)s1.charAt(i) - base;
            
            s1_array[position] = true;
        }
        
        for (int i = 0 ; i < s2.length() ; i++){
            int position = (int)s2.charAt(i) - base;
            
            if (s1_array[position] == true) return "YES";
        }
        
        return "NO";
        }
    
  • + 0 comments
    # Two Strings
    def two_strings(s1, s2):
        return 'YES' if set(s1) & set(s2) else 'NO'
    
  • + 0 comments

    for(let i =0; i

  • + 0 comments

    My recursive C++ solution

    string _str( string & s, string & s1, int n1, int n2)
    {
        if (n1 == 0 || n2 == 0)
        {   
            if( s[0]== s1[0] ) return "YES";
    
            return "NO";
        }
        if (s[n1] == s1[n2])
            return "YES";
    
        return _str(s, s1, n1 - 1, n2 - 1);
    }
    
    string twoStrings(string s1, string s2) 
    {
        return _str(s1, s2, s1.size() - 1, s2.size() - 1);
    }