Banana-Leopard/TASTY huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
/* Function to get index of
   ceiling of x in arr[low..high]*/
int ceilSearch(int arr[], int low, int high, int x)
{
    int mid;
 
    /* If x is smaller than
       or equal to the first element,
       then return the first element */
    if (x <= arr[low])
        return low;
 
    /* If x is greater than the last element,
       then return -1 */
    if (x > arr[high])
        return -1;
 
    /* get the index of middle element of arr[low..high]*/
    mid = (low + high) / 2; /* low + (high - low)/2 */
 
    /* If x is same as middle element,
       then return mid */
    if (arr[mid] == x)
        return mid;
 
    /* If x is greater than arr[mid],
       then either arr[mid + 1] is ceiling of x
       or ceiling lies in arr[mid+1...high] */
    else if (arr[mid] < x) {
        if (mid + 1 <= high && x <= arr[mid + 1])
            return mid + 1;
        else
            return ceilSearch(arr, mid + 1, high, x);
    }
 
    /* If x is smaller than arr[mid],
       then either arr[mid] is ceiling of x
       or ceiling lies in arr[low...mid-1] */
    else {
        if (mid - 1 >= low && x > arr[mid - 1])
            return mid;
        else
            return ceilSearch(arr, low, mid - 1, x);
    }
}
 
// Driver Code
int main()
{
    int arr[] = { 1, 2, 8, 10, 10, 12, 19 };
    int n = sizeof(arr) / sizeof(arr[0]);
    int x = 20;
    int index = ceilSearch(arr, 0, n - 1, x);
    if (index == -1)
        cout << "Ceiling of " << x
             << " doesn't exist in array ";
    else
        cout << "ceiling of " << x << " is " << arr[index];
 
    return 0;
}
 
// This code is contributed by rathbhupendra

Time complexity: logn
Space complexity: constant
#include <bits/stdc++.h>
using namespace std;
 
/* Function to get index of
       ceiling of x in arr[low..high]*/
int ceilSearch(int arr[], int low, int high, int x)
{
 
    // base condition if length of arr == 0 then return -1
    if (x == 0) {
        return -1;
    }
    int mid;
 
    // this while loop function will run until condition not
    // break once condition break loop will return start and
    // ans is low which will be next smallest greater than
    // target which is ceiling
    while (low <= high) {
        mid = low + (high - low) / 2;
        if (arr[mid] == x)
            return mid;
        else if (x < arr[mid])
            high = mid - 1;
        else
            low = mid + 1;
    }
    return low;
}
 
/* step 1 : { low = 1, 2, 8, 10= mid, 10, 12, 19= high};
                if( x < mid) yes set high = mid -1;
   step 2 : { low = 1, 2 = mid, 8 = high, 10, 10, 12,
   19}; if( x < mid) no set low = mid + 1; step 3 : {1, 2, 8
   = high,low,low,  10, 10, 12, 19}; if( x == mid ) yes
   return mid if(x < mid ) no low = mid + 1 step 4  : {1, 2,
   8 = high,mid, 10 = low, 10, 12, 19}; check while(low < =
   high) condition break and return low which will next
   greater of target */
 
/* Driver program to check above functions */
int main()
{
    int arr[] = { 1, 2, 8, 10, 10, 12, 19 };
    int n = sizeof(arr) / sizeof(arr[0]);
    int x = 8;
    int index = ceilSearch(arr, 0, n - 1, x);
    if (index == -1)
        printf("Ceiling of %d does not exist in an array", x);
    else
        printf("Ceiling of %d is %d", x, arr[index]);
    return 0;
}

Time complexity: logn
Space complexity: constant
// Hashing based C++ program to find if there
// is a majority element in input array.
#include <bits/stdc++.h>
using namespace std;
 
// Returns true if there is a majority element
// in a[]
bool isMajority(int a[], int n)
{
    // Insert all elements in a hash table
    unordered_map<int, int> mp;
    for (int i = 0; i < n; i++)
        mp[a[i]]++;
     
    // Check if frequency of any element is
    // n/2 or more.
    for (auto x : mp)
      if (x.second >= n/2)
          return true;
    return false;
}
 
// Driver code
int main()
{
    int a[] = { 2, 3, 9, 2, 2 };
    int n = sizeof(a) / sizeof(a[0]);
    if (isMajority(a, n))
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Time complexity: linear
Space complexity: linear
// A C++ program to find a peak element
// using divide and conquer
#include <bits/stdc++.h>
using namespace std;
 
// A binary search based function
// that returns index of a peak element
int findPeakUtil(int arr[], int low,
                 int high, int n)
{
    // Find index of middle element
    // low + (high - low) / 2
    int mid = low + (high - low) / 2;
 
    // Compare middle element with its
    // neighbours (if neighbours exist)
    if ((mid == 0 || arr[mid - 1] <= arr[mid]) &&
        (mid == n - 1 || arr[mid + 1] <= arr[mid]))
        return mid;
 
    // If middle element is not peak and its
    // left neighbour is greater than it,
    // then left half must have a peak element
    else if (mid > 0 && arr[mid - 1] > arr[mid])
        return findPeakUtil(arr, low, (mid - 1), n);
 
    // If middle element is not peak and its
    // right neighbour is greater than it,
    // then right half must have a peak element
    else
        return findPeakUtil(
            arr, (mid + 1), high, n);
}
 
// A wrapper over recursive function findPeakUtil()
int findPeak(int arr[], int n)
{
    return findPeakUtil(arr, 0, n - 1, n);
}
 
// Driver Code
int main()
{
    int arr[] = { 1, 3, 20, 4, 1, 0 };
    int n = sizeof(arr) / sizeof(arr[0]);
    cout << "Index of a peak point is "
         << findPeak(arr, n);
    return 0;
}
 
// This code is contributed by rajdeep999

Time complexity: logn
Space complexity: logn
// A C++ program to find a peak element
// using divide and conquer
#include <bits/stdc++.h>
using namespace std;
 
// A binary search based function
// that returns index of a peak element
int findPeak(int arr[], int n)
{
    int l = 0;
    int r = n-1;
    int mid;
   
    while (l <= r) {
       
        // finding mid by binary right shifting.
        mid = (l + r) >> 1;
       
        // first case if mid is the answer
        if ((mid == 0 || arr[mid - 1] <= arr[mid])
            and (mid == n - 1 || arr[mid + 1] <= arr[mid]))
            break;
       
        // move the right pointer
        if (mid > 0 and arr[mid - 1] > arr[mid])
            r = mid - 1;
       
        // move the left pointer
        else
            l = mid + 1;
    }
   
    return mid;
}
 
// Driver Code
int main()
{
    int arr[] = { 1, 3, 20, 4, 1, 0 };
    int N = sizeof(arr) / sizeof(arr[0]);
    cout << "Index of a peak point is " << findPeak(arr, N);
    return 0;
}
 
// This code is contributed by Rajdeep Mallick (rajdeep999)

Time complexity: logn
Space complexity: constant
// C++ program to Find the two repeating
// elements in a given array
#include <bits/stdc++.h>
using namespace std;
 
void printTwoRepeatNumber(int arr[], int size)
{
    int i, j;
    cout << "Repeating elements are ";
    for (i = 0; i < size; i++) {
        for (j = i + 1; j < size; j++) {
            if (arr[i] == arr[j]) {
                cout << arr[i] << " ";
                break;
            }
        }
    }
}
 
int main()
{
    int arr[] = { 4, 2, 4, 5, 2, 3, 1 };
    int arr_size = sizeof(arr) / sizeof(arr[0]);
   
    printTwoRepeatNumber(arr, arr_size);
    return 0;
}

Time complexity: quadratic
Space complexity: constant
// C++ implementation of above approach
#include <bits/stdc++.h>
using namespace std;
 
void printRepeating(int arr[], int size)
{
    int* count = new int[sizeof(int) * (size - 2)];
    int i;
 
    cout << " Repeating elements are ";
    for (i = 0; i < size; i++) {
        if (count[arr[i]] == 1)
            cout << arr[i] << " ";
        else
            count[arr[i]]++;
    }
}
 
// Driver code
int main()
{
    int arr[] = { 4, 2, 4, 5, 2, 3, 1 };
    int arr_size = sizeof(arr) / sizeof(arr[0]);
    printRepeating(arr, arr_size);
    return 0;
}
 
// This is code is contributed by rathbhupendra

Time complexity: linear
Space complexity: linear
#include <bits/stdc++.h>
using namespace std;
 
/* function to get factorial of n */
int fact(int n);
 
void printRepeating(int arr[], int size)
{
    int S = 0; /* S is for sum of elements in arr[] */
    int P = 1; /* P is for product of elements in arr[] */
    int x, y; /* x and y are two repeating elements */
    int D; /* D is for difference of x and y, i.e., x-y*/
    int n = size - 2, i;
 
    /* Calculate Sum and Product of all elements in arr[] */
    for (i = 0; i < size; i++) {
        S = S + arr[i];
        P = P * arr[i];
    }
 
    S = S - n * (n + 1) / 2; /* S is x + y now */
    P = P / fact(n); /* P is x*y now */
 
    D = sqrt(S * S - 4 * P); /* D is x - y now */
 
    x = (D + S) / 2;
    y = (S - D) / 2;
 
    cout << "Repeating elements are " << x << " " << y;
}
 
int fact(int n) { return (n == 0) ? 1 : n * fact(n - 1); }
 
// Driver code
int main()
{
    int arr[] = { 4, 2, 4, 5, 2, 3, 1 };
    int arr_size = sizeof(arr) / sizeof(arr[0]);
    printRepeating(arr, arr_size);
    return 0;
}
 
// This code is contributed by rathbhupendra

Time complexity: linear
Space complexity: constant
#include <bits/stdc++.h>
using namespace std;
 
void printRepeating(int arr[], int size)
{
    int Xor = arr[0]; /* Will hold Xor of all elements */
    int set_bit_no; /* Will have only single set bit of Xor
                     */
    int i;
    int n = size - 2;
    int x = 0, y = 0;
 
    /* Get the Xor of all elements in arr[] and {1, 2 .. n}
     */
    for (i = 1; i < size; i++)
        Xor ^= arr[i];
    for (i = 1; i <= n; i++)
        Xor ^= i;
 
    /* Get the rightmost set bit in set_bit_no */
    set_bit_no = Xor & ~(Xor - 1);
 
    /* Now divide elements in two sets by comparing
    rightmost set bit of Xor with bit at same position in
    each element. */
    for (i = 0; i < size; i++) {
        if (arr[i] & set_bit_no)
            x = x ^ arr[i]; /*Xor of first set in arr[] */
        else
            y = y ^ arr[i]; /*Xor of second set in arr[] */
    }
    for (i = 1; i <= n; i++) {
        if (i & set_bit_no)
            x = x ^ i; /*Xor of first set in arr[] and {1,
                          2, ...n }*/
        else
            y = y ^ i; /*Xor of second set in arr[] and {1,
                          2, ...n } */
    }
 
    cout << "Repeating elements are " << y << " " << x;
}
 
// Driver code
int main()
{
    int arr[] = { 4, 2, 4, 5, 2, 3, 1 };
    int arr_size = sizeof(arr) / sizeof(arr[0]);
    printRepeating(arr, arr_size);
    return 0;
}
 
// This code is contributed by rathbhupendra

Time complexity: linear
Space complexity: constant
#include <bits/stdc++.h>
using namespace std;
 
void printRepeating(int arr[], int size)
{
    int i;
 
    cout << "Repeating elements are ";
 
    for (i = 0; i < size; i++) {
        if (arr[abs(arr[i])] > 0)
            arr[abs(arr[i])] = -arr[abs(arr[i])];
        else
            cout << abs(arr[i]) << " ";
    }
}
 
// Driver code
int main()
{
    int arr[] = { 4, 2, 4, 5, 2, 3, 1 };
    int arr_size = sizeof(arr) / sizeof(arr[0]);
    printRepeating(arr, arr_size);
    return 0;
}
 
// This code is contributed by rathbhupendra

Time complexity: linear
Space complexity: constant
#include <bits/stdc++.h>
using namespace std;
 
void twoRepeated(int arr[], int N)
{
    int m = N - 1;
    for (int i = 0; i < N; i++) {
        arr[arr[i] % m - 1] += m;
        if ((arr[arr[i] % m - 1] / m) == 2)
            cout << arr[i] % m << " ";
    }
}
// Driver Code
int main()
{
    int arr[] = { 4, 2, 4, 5, 2, 3, 1 };
    int n = sizeof(arr) / sizeof(arr[0]);
    cout << "Repeating elements are ";
    twoRepeated(arr, n);
 
    return 0;
}
 
// This code is contributed by Aditya Kumar (adityakumar129)

Time complexity: linear
Space complexity: constant
// C++ program to Find the two repeating
// elements in a given array
#include <bits/stdc++.h>
using namespace std;
 
void printRepeating(int arr[], int size)
{
    unordered_set<int> s;
    cout << "Repeating elements are ";
    for (int i = 0; i < size; i++) {
        if (s.empty() == false && s.find(arr[i]) != s.end())
            cout << arr[i] << "  ";
        s.insert(arr[i]);
    }
}
 
// Driver code
int main()
{
    int arr[] = { 4, 2, 4, 5, 2, 3, 1 };
    int arr_size = sizeof(arr) / sizeof(arr[0]);
    printRepeating(arr, arr_size);
    return 0;
}
 
// This code is contributed by nakul amate

Time complexity: linear
Space complexity: linear
/* A simple program to print subarray
with sum as given sum */
#include <bits/stdc++.h>
using namespace std;
 
/* Returns true if the there is a subarray
of arr[] with sum equal to 'sum' otherwise
returns false. Also, prints the result */
void subArraySum(int arr[], int n, int sum)
{
 
    // Pick a starting point
    for (int i = 0; i < n; i++) {
        int currentSum = arr[i];
 
        if (currentSum == sum) {
            cout << "Sum found at indexes " << i << endl;
            return;
        }
        else {
            // Try all subarrays starting with 'i'
            for (int j = i + 1; j < n; j++) {
                currentSum += arr[j];
 
                if (currentSum == sum) {
                    cout << "Sum found between indexes "
                         << i << " and " << j << endl;
                    return;
                }
            }
        }
    }
    cout << "No subarray found";
    return;
}
 
// Driver Code
int main()
{
    int arr[] = { 15, 2, 4, 8, 9, 5, 10, 23 };
    int n = sizeof(arr) / sizeof(arr[0]);
    int sum = 23;
    subArraySum(arr, n, sum);
    return 0;
}
 
// This code is contributed
// by rathbhupendra

Time complexity: quadratic
Space complexity: constant
/* An efficient program to print
subarray with sum as given sum */
#include <iostream>
using namespace std;
 
/* Returns true if the there is a subarray of
arr[] with a sum equal to 'sum' otherwise
returns false. Also, prints the result */
int subArraySum(int arr[], int n, int sum)
{
    /* Initialize currentSum as value of
    first element and starting point as 0 */
    int currentSum = arr[0], start = 0, i;
 
    /* Add elements one by one to currentSum and
    if the currentSum exceeds the sum,
    then remove starting element */
    for (i = 1; i <= n; i++) {
        // If currentSum exceeds the sum,
        // then remove the starting elements
        while (currentSum > sum && start < i - 1) {
            currentSum = currentSum - arr[start];
            start++;
        }
 
        // If currentSum becomes equal to sum,
        // then return true
        if (currentSum == sum) {
            cout << "Sum found between indexes " << start
                 << " and " << i - 1;
            return 1;
        }
 
        // Add this element to currentSum
        if (i < n)
            currentSum = currentSum + arr[i];
    }
 
    // If we reach here, then no subarray
    cout << "No subarray found";
    return 0;
}
 
// Driver Code
int main()
{
    int arr[] = { 15, 2, 4, 8, 9, 5, 10, 23 };
    int n = sizeof(arr) / sizeof(arr[0]);
    int sum = 23;
    subArraySum(arr, n, sum);
    return 0;
}
 
// This code is contributed by SHUBHAMSINGH10

Time complexity: linear
Space complexity: constant
// C++ implementation of smallest difference triplet
#include <bits/stdc++.h>
using namespace std;
 
// function to find maximum number
int maximum(int a, int b, int c)
{
   return max(max(a, b), c);
}
 
// function to find minimum number
int minimum(int a, int b, int c)
{
   return min(min(a, b), c);
}
 
// Finds and prints the smallest Difference Triplet
void smallestDifferenceTriplet(int arr1[], int arr2[],
                                    int arr3[], int n)
{
    // sorting all the three arrays
    sort(arr1, arr1+n);
    sort(arr2, arr2+n);
    sort(arr3, arr3+n);
 
    // To store resultant three numbers
    int res_min, res_max, res_mid;
 
    // pointers to arr1, arr2, arr3
    // respectively
    int i = 0, j = 0, k = 0;
 
    // Loop until one array reaches to its end
    // Find the smallest difference.
    int diff = INT_MAX;
    while (i < n && j < n && k < n)
    {
        int sum = arr1[i] + arr2[j] + arr3[k];
 
        // maximum number
        int max = maximum(arr1[i], arr2[j], arr3[k]);
 
        // Find minimum and increment its index.
        int min = minimum(arr1[i], arr2[j], arr3[k]);
        if (min == arr1[i])
            i++;
        else if (min == arr2[j])
            j++;
        else
            k++;
 
        // comparing new difference with the
        // previous one and updating accordingly
        if (diff > (max-min))
        {
            diff = max - min;
            res_max = max;
            res_mid = sum - (max + min);
            res_min = min;
        }
    }
 
    // Print result
    cout << res_max << ", " << res_mid << ", " << res_min;
}
 
// Driver program to test above
int main()
{
    int arr1[] = {5, 2, 8};
    int arr2[] = {10, 7, 12};
    int arr3[] = {9, 14, 6};
    int n = sizeof(arr1) / sizeof(arr1[0]);
    smallestDifferenceTriplet(arr1, arr2, arr3, n);
    return 0;
}

Time complexity: nlogn
Space complexity: constant
// A simple C++ program to find three elements
// whose sum is equal to zero
#include <bits/stdc++.h>
using namespace std;
 
// Prints all triplets in arr[] with 0 sum
void findTriplets(int arr[], int n)
{
    bool found = false;
    for (int i = 0; i < n - 2; i++) {
        for (int j = i + 1; j < n - 1; j++) {
            for (int k = j + 1; k < n; k++) {
                if (arr[i] + arr[j] + arr[k] == 0) {
                    cout << arr[i] << " " << arr[j] << " "
                         << arr[k] << endl;
                    found = true;
                }
            }
        }
    }
 
    // If no triplet with 0 sum found in array
    if (found == false)
        cout << " not exist " << endl;
}
 
// Driver code
int main()
{
    int arr[] = { 0, -1, 2, -3, 1 };
    int n = sizeof(arr) / sizeof(arr[0]);
    findTriplets(arr, n);
    return 0;
}
 
// This code is contributed by Aditya Kumar (adityakumar129)

Time complexity: cubic
Space complexity: constant
// C++ program to find triplets in a given
// array whose sum is zero
#include <bits/stdc++.h>
using namespace std;
 
// function to print triplets with 0 sum
void findTriplets(int arr[], int n)
{
    bool found = false;
 
    for (int i = 0; i < n - 1; i++) {
        // Find all pairs with sum equals to
        // "-arr[i]"
        unordered_set<int> s;
        for (int j = i + 1; j < n; j++) {
            int x = -(arr[i] + arr[j]);
            if (s.find(x) != s.end()) {
                printf("%d %d %d\n", x, arr[i], arr[j]);
                found = true;
            }
            else
                s.insert(arr[j]);
        }
    }
 
    if (found == false)
        cout << " No Triplet Found" << endl;
}
 
// Driver code
int main()
{
    int arr[] = { 0, -1, 2, -3, 1 };
    int n = sizeof(arr) / sizeof(arr[0]);
    findTriplets(arr, n);
    return 0;
}

Time complexity: quadratic
Space complexity: linear
// C++ program to find triplets in a given
// array whose sum is zero
#include <bits/stdc++.h>
using namespace std;
 
// function to print triplets with 0 sum
void findTriplets(int arr[], int n)
{
    bool found = false;
 
    // sort array elements
    sort(arr, arr + n);
 
    for (int i = 0; i < n - 1; i++) {
        // initialize left and right
        int l = i + 1;
        int r = n - 1;
        int x = arr[i];
        while (l < r) {
            if (x + arr[l] + arr[r] == 0) {
                // print elements if it's sum is zero
                printf("%d %d %d\n", x, arr[l], arr[r]);
                l++;
                r--;
                found = true;
                //   break;
            }
 
            // If sum of three elements is less
            // than zero then increment in left
            else if (x + arr[l] + arr[r] < 0)
                l++;
 
            // if sum is greater than zero then
            // decrement in right side
            else
                r--;
        }
    }
 
    if (found == false)
        cout << " No Triplet Found" << endl;
}
 
// Driven source
int main()
{
    int arr[] = { 0, -1, 2, -3, 1 };
    int n = sizeof(arr) / sizeof(arr[0]);
    findTriplets(arr, n);
    return 0;
}

Time complexity: quadratic
Space complexity: constant
// C++ program to rotate a matrix
 
#include <bits/stdc++.h>
#define R 4
#define C 4
using namespace std;
 
// A function to rotate a matrix mat[][] of size R x C.
// Initially, m = R and n = C
void rotatematrix(int m, int n, int mat[R][C])
{
    int row = 0, col = 0;
    int prev, curr;
 
    /*
    row - Starting row index
    m - ending row index
    col - starting column index
    n - ending column index
    i - iterator
    */
    while (row < m && col < n)
    {
 
        if (row + 1 == m || col + 1 == n)
            break;
 
        // Store the first element of next row, this
        // element will replace first element of current
        // row
        prev = mat[row + 1][col];
 
        /* Move elements of first row from the remaining rows */
        for (int i = col; i < n; i++)
        {
            curr = mat[row][i];
            mat[row][i] = prev;
            prev = curr;
        }
        row++;
 
        /* Move elements of last column from the remaining columns */
        for (int i = row; i < m; i++)
        {
            curr = mat[i][n-1];
            mat[i][n-1] = prev;
            prev = curr;
        }
        n--;
 
        /* Move elements of last row from the remaining rows */
        if (row < m)
        {
            for (int i = n-1; i >= col; i--)
            {
                curr = mat[m-1][i];
                mat[m-1][i] = prev;
                prev = curr;
            }
        }
        m--;
 
        /* Move elements of first column from the remaining rows */
        if (col < n)
        {
            for (int i = m-1; i >= row; i--)
            {
                curr = mat[i][col];
                mat[i][col] = prev;
                prev = curr;
            }
        }
        col++;
    }
 
    // Print rotated matrix
    for (int i=0; i<R; i++)
    {
        for (int j=0; j<C; j++)
        cout << mat[i][j] << " ";
        cout << endl;
    }
}
 
/* Driver program to test above functions */
int main()
{
    // Test Case 1
    int a[R][C] = { {1, 2, 3, 4},
        {5, 6, 7, 8},
        {9, 10, 11, 12},
        {13, 14, 15, 16} };
 
    // Test Case 2
    /* int a[R][C] = {{1, 2, 3},
                    {4, 5, 6},
                    {7, 8, 9}
                    };
    */ rotatematrix(R, C, a);
    return 0;
}

Time complexity: quadratic
Space complexity: constant
// C++ program to rotate a matrix
// by 90 degrees
#include <bits/stdc++.h>
#define N 4
using namespace std;
 
// An Inplace function to
// rotate a N x N matrix
// by 90 degrees in
// anti-clockwise direction
void rotateMatrix(int mat[][N])
{
    // Consider all squares one by one
    for (int x = 0; x < N / 2; x++) {
        // Consider elements in group
        // of 4 in current square
        for (int y = x; y < N - x - 1; y++) {
            // Store current cell in
            // temp variable
            int temp = mat[x][y];
 
            // Move values from right to top
            mat[x][y] = mat[y][N - 1 - x];
 
            // Move values from bottom to right
            mat[y][N - 1 - x] = mat[N - 1 - x][N - 1 - y];
 
            // Move values from left to bottom
            mat[N - 1 - x][N - 1 - y] = mat[N - 1 - y][x];
 
            // Assign temp to left
            mat[N - 1 - y][x] = temp;
        }
    }
}
 
// Function to print the matrix
void displayMatrix(int mat[N][N])
{
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << mat[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;
}
 
/* Driver code */
int main()
{
    // Test Case 1
    int mat[N][N] = { { 1, 2, 3, 4 },
                      { 5, 6, 7, 8 },
                      { 9, 10, 11, 12 },
                      { 13, 14, 15, 16 } };
 
    // Function call
    rotateMatrix(mat);
 
    // Print rotated matrix
    displayMatrix(mat);
 
    return 0;
}

Time complexity: quadratic
Space complexity: constant