Monday, 29 Nov 2021
Category: rotation

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 […]

Reduce the given Array of [1, N] by rotating left or right based on given conditionsGiven a sorted array arr[] of the first N Natural Numbers and an integer X, the task is to print the last remaining element after performing the below operations (N – 1) times:Examples:Input: N = 5, arr[] = {1, 2, […]

#include using namespace std;  string findRotation(vector& mat,                    vector& T){            if (T.size() != mat.size()        || T.size() != mat.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.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] += […]

#include using namespace std;  void print(vector& mat){        for (int i = 0; i < mat.size(); i++) {                  for (int j = 0; j < mat.size(); j++)                          cout

Maximum number of 0s placed consecutively at the start and end in any rotation of a Binary String Given a binary string S of size N, the task is to maximize sum of count of consecutive 0s present at the start and end of any of the rotations of the given string S. Examples: Input: […]

Given a matrix mat[][] of dimensions M * N, the task is to print the matrix obtained after rotating every ith row of the matrix i times in a clockwise direction. Examples: Input: mat[][] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}Output:1 2 36 4 58 9 7Explanation:The 0th row is rotated 0 […]

Check if all array elements can be converted to pronic numbers by rotating digits Given an array arr[] of size N, the task is to check if it is possible to convert all of array elements to a pronic number by rotating the digits of array elements any number of times. Examples: Input: {321, 402, […]