• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
May 25, 2023 |1.4K Views

Check if all rows of a matrix are circular rotations of each other

  Share   Like
Description
Discussion

In this video, we will discuss a problem in which given a matrix of n*n size, the task is to find whether all rows are circular rotations of each other or not.

Examples: 

  • Input: mat[][] = 1, 2, 3
                               3, 1, 2
                               2, 3, 1
    Output:  Yes
    All rows are rotated permutation
    of each other.
     
  • Input: mat[3][3] = 1, 2, 3
                                   3, 2, 1
                                   1, 3, 2
    Output:  No
    Explanation : As 3, 2, 1 is not a rotated or 
    circular permutation of 1, 2, 3

Go through the video to understand complete implementation of the problem. We recommend you to try out the problem yourself first. All the best!!!


Article:  https://www.geeksforgeeks.org/check-rows-matrix-circular-rotations/
SDE Sheet: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/