Google | Phone | Calculate Column Width
Anonymous User
2966

Position interviewed for - New Grad SDE
Location - USA
Experience - 0 years.

This was the question asked for google phone interview round :

Q: Given the maxWidth (characters that could fit in one line) and an array of strings, fit the strings in a table and return the width of each column.

Input - W = 70 (characters) (maxWidth)
S = [IsAudioBuffer, GetTimestamp, SetTimestamp, GetSampleRate, GetSampleSize, GetNumberOfChannels, GetNumberOfSamples, GetDataBuffer, GetChannel]

Output -

IsAudioBuffer  | GetTimestamp          | SetTimestamp | GetSampleRate |
GetSampleSize| GetNumberOfChannels| GetNumberOfSamples| GetDataBuffer  |
GetChannel     |

public List<Integer> calculateColumnWidth(String[] words, int maxWidth) {
}

It would be great if someone can give possible solutions?

Thanks!

Comments (5)