Generate all rotations of a given string | Prvar all the rotated string . ; Concatenate str with itself ; Prvar all substrings of size n . Note that size of sb is 2 n ; Driver method
function printRotatedString ( str ) { var n = str . length ; var sb = str ; sb += ( str ) ; for ( var i = 0 ; i < n ; i ++ ) { for ( var j = 0 ; j != n ; j ++ ) document . write ( sb . charAt ( i + j ) ) ; document . write ( ' ' ) ; } } var str = " " ; printRotatedString ( str ) ;