Beginner Friendly
📝 Approach
When a left shift occurs, only the left-most element moves to the right.
When a right shift occurs, only the right-most element moves to the left.
💻
# 📝 Approach

- When a **left shift** occurs, only the **left-most element** moves to the **right**.
- When a **right shift** occurs, only the **right-most element** moves to the **left**.
---
# 💻 Code
```cpp
class Solution {
public:
    bool areSimilar(vector<vector<int>>& mat, int k) {
        vector<vector<int>> grid = mat;
        while (k > 0) {
            for (int i = 0; i < grid.size(); i += 2) {
                int temp = grid[i][0];
                grid[i].erase(grid[i].begin());
                grid[i].push_back(temp);
            }
            for (int i = 1; i < grid.size(); i += 2) {
                int temp2 = grid[i].back();
                grid[i].pop_back();
                grid[i].insert(grid[i].begin(), temp2);
            }
            k--; 
        }
        return grid == mat;
    }
};

['C++']