W solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nWe create a copy of the vector (cpy) and then loop through each row. We h
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nWe create a copy of the vector (cpy) and then loop through each row. We have a check_row function which validates or invalidates the two vectors equality. If they are distinct from each other, we can immediately return false as the matrix is different. The shift_row function works by checking if i (the loop iteration) is even or odd. It then uses that data to dictate whether to do a left or right shift. It does said shift k times.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    std::vector<int> shift_row(std::vector<int> row, int k, int i){\n        bool even = !(i % 2);\n        for(int z = 0; z < k; z++){\n            if(!even){\n                auto b = row.back();\n                row.pop_back();\n                row.insert(row.begin(), b);\n            }else{\n                auto b = row.front();\n                row.erase(row.begin());\n                row.emplace_back(b);\n            }\n        }\n        return row;\n    }\n    bool check_row(std::vector<int>& mrow, std::vector<int> crow)\n    {\n        for(int i = 0; i < mrow.size(); i++){\n            if(mrow[i] != crow[i]){return false;}\n        }\n        return true;\n    }\n    bool areSimilar(vector<vector<int>>& mat, int k) {\n        auto cpy = mat;\n        for(int r = 0; r < mat.size(); r++){\n            if(check_row(mat[r], shift_row(mat[r], k, r)) == false){return false;}\n        }\n        return true;\n    }\n};\n```
['C++']