Print an N x M matrix such that each row and column has all the vowels in it | Function to print the required matrix ; Impossible to generate the required matrix ; Store all the vowels ; Print the matrix ; Print vowels for every index ; Shift the vowels by one ; Driver code
function printMatrix ( n , m ) { if ( n < 5 m < 5 ) { document . write ( - 1 ) ; return ; } var s = " " ; for ( var i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < m ; j ++ ) { document . write ( s [ j % 5 ] + " " ) ; } document . write ( " " ) ; var c = s [ 0 ] ; s = s . substring ( 1 , s . length ) + s . substring ( 0 , 1 ) ; s [ 4 ] = c ; } } var n = 5 , m = 5 ; printMatrix ( n , m ) ;