DXC Technology Interview Question

Q: Given an array of strings, return the common beginning substring.

Interview Answer

Anonymous

Oct 10, 2022

I sorted the array and took the first element as the answer. Then I looped from second to last element and for each element I compared the answer string with current string to find the common beginning substring.