1-liner in Ruby


  • 1
    def rotate(matrix)
      matrix.replace(matrix.reverse.transpose)
    end
    

    I like Ruby's wordy style.


  • 0
    Q

    can this pass the test?In that case ,I'll spare my time to learn something about Ruby.


  • 0

    Yes, it passes. Why would I post something as a solution if it didn't? You could've also just tried it...

    Ruby is fun, I definitely recommend learning it :-)


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.