"If you do nothing, nothing will happen."

프로그래밍

[HackerRank] Sparse Arrays

tedhong 2023. 2. 20. 12:54
2019-05-28 글쓴이 TED HONG

[HackerRank] Sparse Arrays

오늘 문제는 너무 기초네..;;; 

주어진 배열안에 검색어가 몇 개인지 찾는 문제..;;

 

static int[] matchingStrings(string[] strings, string[] queries) {
        List result = new List();
        foreach(string q in queries)
        {
            result.Add(GetContainsCount(strings, q));
        }
        return result.ToArray();
    }

    static int GetContainsCount(string[] arr, string q)
    {
        List list = new List(arr);
        int result = list.Count(x => q.Contains(x));
        return result;
    }

'프로그래밍' 카테고리의 다른 글

[HackerRank] Number of ID  (0) 2023.02.20
[HackerRank] Common Child  (0) 2023.02.20
[Hackerrank] Left Rotation  (0) 2023.02.20
[HackerRank] Sherlock and Anagrams  (0) 2023.02.20
[HackerRank] New Year Chaos  (0) 2023.02.20