MCPcopy Create free account
hub / github.com/chaharnishant11/CodeIn10DSA / Solution

Class Solution

C++/Code/rotateArray.cpp:12–32  ·  view source on GitHub ↗

} Driver Code Ends

Source from the content-addressed store, hash-verified

10
11 // } Driver Code Ends
12class Solution{
13 public:
14 void reverse(int arr[], int start,int end){
15 while(start<end){
16 int temp = arr[start];
17 arr[start] = arr[end];
18 arr[end] = temp;
19 start++;
20 end--;
21 }
22 }
23 //Function to rotate an array by d elements in counter-clockwise direction.
24 void rotateArr(int arr[], int d, int n){
25
26 // code here
27 d=d%n;
28 reverse(arr,0,d-1);
29 reverse(arr,d,n-1);
30 reverse(arr,0,n-1);
31 }
32};
33
34// { Driver Code Starts.
35

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected