• + 0 comments

    c#

    public static string canConstruct(List a)

    {
    // Return "Yes" or "No" denoting whether you can construct the required number.
        string answer = "No";
        var digits = new List<int>();
        for (int i = 0; i < a.Count; i++)
        {
            while (a[i] > 0)
            {
                digits.Add(a[i]%10);
                a[i] /= 10;
            }
        }
        int sumList = digits.Sum();
        if (sumList % 3 == 0)
        {
            answer = "Yes";
        }
        return answer;
    }