public class Solution {
public string LongestCommonPrefix(string[] strs) {
string res = "";
StringBuilder sb = new StringBuilder();
for (int i = 0; i < strs.Length; i++)
{
string commonChars = string.Concat(strs
.Select(strs=>strs.AsEnumerable())
.Aggregate((s,a)=>s.Intersect(a))
.OrderBy(c=>c)
);
res = commonChars;
}
return res;
}
}
public class Solution {
public string LongestCommonPrefix(string[] strs) {
string res = "";
StringBuilder sb = new StringBuilder();
for (int i = 0; i < strs.Length; i++)
{
string commonChars = string.Concat(strs
.Select(strs=>strs.AsEnumerable())
.Aggregate((s,a)=>s.Intersect(a))
.OrderBy(c=>c)
);
res = commonChars;
}
return res;
}
}