100% beats easy soln, use rotate.
IntuitionApproachfor even rows left shift, the middle element becomes first and first goes to last  thus use rotate to reduce complexity
rotate(mat[i].begin(),m
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->
for even rows left shift, the middle element becomes first and first goes to last  thus use rotate to reduce complexity
rotate(mat[i].begin(),mat[i].begin()+1,mat[i].end())

For odd row right shift so
rotate(mat[i].rbegin(),mat[i].rbegin()+1,mat[i].rend());
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    bool areSimilar(vector<vector<int>>& mat, int k) {
        int m= mat.size();
        int n= mat[0].size();

        vector<vector<int>> original = mat;

        for(int step=0;step<k;++step){
            for(int i=0;i<m;++i){
                if(i%2==0){
                    rotate(mat[i].begin(),mat[i].begin()+1,mat[i].end());
                }else{
                    rotate(mat[i].rbegin(),mat[i].rbegin()+1,mat[i].rend());
                }
            }
        }
        return mat==original;
            

    }
};
```
![d9a30a34-57a0-40f1-adab-43bec86a259a_1723795301.0363479.png](https://assets.leetcode.com/users/images/83c389ee-3e1b-4207-93bb-7dc2f1e57dbb_1735999112.1955383.png)

['C++']