<s> class Solution : <EOL> def rotate ( self , matrix ) : <EOL> n = len ( matrix ) <EOL> for i in xrange ( n ) : <EOL> for j in xrange ( n - i ) : <EOL> matrix [ i ] [ j ] , matrix [ n - <NUM_LIT:1> - j ] [ n - <NUM_LIT:1> - i ] = matrix [ n - <NUM_LIT:1> - j ] [ n - <NUM_LIT:1> - i ] , matrix [ i ] [ j ] <EOL> for i in xrange ( n / <NUM_LIT:2> ) : <EOL> for j in xrange ( n ) : <EOL> matrix [ i ] [ j ] , matrix [ n - <NUM_LIT:1> - i ] [ j ] = matrix [ n - <NUM_LIT:1> - i ] [ j ] , matrix [ i ] [ j ] <EOL> return matrix <EOL> class Solution2 : <EOL> def rotate ( self , matrix ) : <EOL> return [ list ( reversed ( x ) ) for x in zip ( * matrix ) ] <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> matrix = [ [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] , [ <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> ] ] <EOL> print Solution ( ) . rotate ( matrix ) </s>
