HackerEarth Rubik Square problem solution YASH PAL, 31 July 2024 In this HackerEarth Rubik’s Square problem solution Raj has bought a new Rubik’s Cube and he try to solve it day and night. Seeing this , Vikas tried to help Raj by giving him problem based on cube Rotation . To make it easier for Raj , As Raj is a beginner Vikas gave problem in square matrix instead of cube. The problem is as follows : Vikas has N*N array of different numbers. Now he rotates the rows and columns . Raj has to stay focused and tell Vikas what should be output of matrix after R Rows Rotation and C columns rotation. Raj is now more confused then ever from the above problem. Help him to find the answer. HackerEarth Rubik’s Square problem solution. using namespace std;int main(){ // freopen("sampleinput.txt","r",stdin); // freopen("sampleoutput.txt","w",stdout); int n,rr,cc; cin>>n>>rr>>cc; int a[n][n]; for(int i=0;i>a[i][j]; } } int r[n],c[n]; memset(r,0,sizeof(r)); memset(c,0,sizeof(c));for(int i=0;i<rr;i++){ int t; cin>>t; r[t-1]++; r[t-1]=r[t-1]%n;}for(int i=0;i<cc;i++){ int t; cin>>t; c[t-1]++; c[t-1]=c[t-1]%n;}int b[n][n];//memset(b,0,sizeof(b)*n*n);for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ b[i][j]= a[i][(n-r[i]+j)%n] ; }}for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ a[i][j]= b[(n-c[j]+i)%n][j] ; }}for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ cout<<a[i][j]<<" "; } cout<<endl;}} coding problems