Ad
Code
Diff
  • using System.Collections.Generic;
    
    public class Kata
    {
        public static bool ContainsCommonItem(char[] a, char[] b)
        {
            if (a == null || b == null) return false;
            
            return new HashSet<char>(a).Overlaps(b);
        }
    }
    
    • using System.Collections.Generic;
    • public class Kata
    • {
    • public static bool ContainsCommonItem(char[] a, char[] b)
    • {
    • if (a == null || b == null) {
    • return false;
    • }
    • if (a == null || b == null) return false;
    • HashSet<char> setA = new HashSet<char>(a);
    • foreach (char item in b)
    • {
    • if (item != null && setA.Contains(item))
    • {
    • return true;
    • }
    • }
    • return false;
    • return new HashSet<char>(a).Overlaps(b);
    • }
    • }