You are viewing a single comment's thread. Return to all 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; }
Seems like cookies are disabled on this browser, please enable them to open this website
Constructing a Number
You are viewing a single comment's thread. Return to all comments →
c#
public static string canConstruct(List a)