Largest Square Matrix - Words
Largest Square Matrix - Words PROBLEM STATEMENT : The program must accept a string S containing multiple words as the input. The program must form the largest possible square matrix of size N*N based on the following conditions. - The words of equal length must be used to form the square matrix (i.e., each row in the matrix contains all the characters of a word). - The words in the given string must be used in the order of their occurrence. Finally, the program must print the largest possible square matrix as the output. If there are two or more such largest square matrices, the program must print the matrix with the first N words of length N as the output. If it is not possible to form such a matrix, the program must print -1 as the output. Boundary Condition(s): 1 <= Length of S <= 1000 Input Format: The first line contains S. Output Format: The lines contain the largest possible square matrix or the first line c...