Category: rotation

Print array after it is right rotated K times | Set 2

Given an array arr[] of size N and a value K, the task is to print the array rotated by K times to the right.Examples:Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.  To complete your […]

Continue Reading

Check whether Matrix T is a result of one or more 90° rotations of Matrix mat

#include using namespace std;  string findRotation(vector& mat,                    vector& T){            if (T.size() != mat.size()        || T[0].size() != mat[0].size()) {                return “No”;    }              map m;          for (int i = 0; i < mat.size(); i++) {                          m[mat[i]] += 1;                  reverse(mat[i].begin(), mat[i].end());                          m[mat[i]] += 1;    }          for (int i = 0; i < mat[0].size(); i++) {                  vector r = {};                  for (int j = 0; j < mat.size(); j++) {            r.push_back(mat[j][i]);        }                          m[r] += 1;                  reverse(r.begin(), r.end());                          m[r] += […]

Continue Reading