How to solve the following question?
Anonymous User
904

I've come across the following question recently during my onsite interview,

Consider an online editor like Google Docs and consider a table which is of 1x2 size. Given input string consider like,

["leet code community discuss forum", "data structure and algorithm questions and patterns"]

The first string should fit within first coloum in the 1x2 table and the second string should fit within second column of the table.

Constraints:

  • There would be page width limit (say ex; you can have maximum of 50 characters in a line).
  • Words should not break when they do not fit within the line limit

With these constraints in mind, how would you split the column (c1 + c2 = line_length) so that the input strings can fit in minimum number of rows?

How can we solve this?

Comments (3)