DEV Community

Miss Pooja Anilkumar Patel
Miss Pooja Anilkumar Patel

Posted on • Updated on

48. Leetcode Solution in Cpp

class Solution {
 public:
  void rotate(vector<vector<int>>& matrix) {
    reverse(begin(matrix), end(matrix));
    for (int i = 0; i < matrix.size(); ++i)
      for (int j = i + 1; j < matrix.size(); ++j)
        swap(matrix[i][j], matrix[j][i]);
  }
};
Enter fullscreen mode Exit fullscreen mode

leetcode

challenge

Here is the link for the problem:
https://leetcode.com/problems/rotate-image/

Top comments (0)