Banana-Leopard/TASTY huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
void findCommon(int a[], int b[], int c[], int n1, int n2,
                int n3)
{
    // three sets to maintain frequency of elements
    unordered_set<int> uset, uset2, uset3;
    for (int i = 0; i < n1; i++) {
        uset.insert(a[i]);
    }
    for (int i = 0; i < n2; i++) {
        uset2.insert(b[i]);
    }
    // checking if elements of 3rd array are present in
    // first 2 sets
    for (int i = 0; i < n3; i++) {
        if (uset.find(c[i]) != uset.end()
            && uset2.find(c[i]) != uset.end()) {
            // using a 3rd set to prevent duplicates
            if (uset3.find(c[i]) == uset3.end())
                cout << c[i] << " ";
            uset3.insert(c[i]);
        }
    }
}
 
// Driver code
int main()
{
    int ar1[] = { 1, 5, 10, 20, 40, 80 };
    int ar2[] = { 6, 7, 20, 80, 100 };
    int ar3[] = { 3, 4, 15, 20, 30, 70, 80, 120 };
    int n1 = sizeof(ar1) / sizeof(ar1[0]);
    int n2 = sizeof(ar2) / sizeof(ar2[0]);
    int n3 = sizeof(ar3) / sizeof(ar3[0]);
 
    cout << "Common Elements are " << endl;
    findCommon(ar1, ar2, ar3, n1, n2, n3);
    return 0;
}

Time complexity: linear
Space complexity: linear
// C++ program to find the only repeating
// element in an array where elements are
// from 1 to N-1.
#include <bits/stdc++.h>
using namespace std;
 
int findRepeating(int arr[], int N)
{
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (arr[i] == arr[j])
                return arr[i];
        }
    }
}
 
// Driver's code
int main()
{
    int arr[] = { 9, 8, 2, 6, 1, 8, 5, 3, 4, 7 };
    int N = sizeof(arr) / sizeof(arr[0]);
 
    // Function call
    cout << findRepeating(arr, N);
    return 0;
}
// This code is added by Arpit Jain

Time complexity: quadratic
Space complexity: constant
// CPP program to find the only repeating
// element in an array where elements are
// from 1 to N-1.
#include <bits/stdc++.h>
using namespace std;
 
int findRepeating(int arr[], int N)
{
    sort(arr, arr + N); // sort array
 
    for (int i = 0; i < N; i++) {
 
        // compare array element with its index
        if (arr[i] != i + 1) {
            return arr[i];
        }
    }
    return -1;
}
 
// driver's code
int main()
{
    int arr[] = { 9, 8, 2, 6, 1, 8, 5, 3, 4, 7 };
    int N = sizeof(arr) / sizeof(arr[0]);
 
    // Function call
    cout << findRepeating(arr, N);
    return 0;
}
// this code is contributed by devendra solunke

Time complexity: nlogn
Space complexity: constant
// C++ program to find the only repeating
// element in an array where elements are
// from 1 to N-1.
 
#include <bits/stdc++.h>
using namespace std;
 
int findRepeating(int arr[], int N)
{
    unordered_set<int> s;
    for (int i = 0; i < N; i++) {
        if (s.find(arr[i]) != s.end())
            return arr[i];
        s.insert(arr[i]);
    }
 
    // If input is correct, we should
    // never reach here
    return -1;
}
 
// Driver's code
int main()
{
    int arr[] = { 9, 8, 2, 6, 1, 8, 5, 3, 4, 7 };
    int N = sizeof(arr) / sizeof(arr[0]);
   
      // Function call
    cout << findRepeating(arr, N);
    return 0;
}

Time complexity: linear
Space complexity: linear
// CPP program to find the only repeating
// element in an array where elements are
// from 1 to N-1.
#include <bits/stdc++.h>
using namespace std;
 
int findRepeating(int arr[], int N)
{
    // Find array sum and subtract sum
    // first N-1 natural numbers from it
    // to find the result.
    return accumulate(arr, arr + N, 0) - ((N - 1) * N / 2);
}
 
// Driver's code
int main()
{
    int arr[] = { 9, 8, 2, 6, 1, 8, 5, 3, 4, 7 };
    int N = sizeof(arr) / sizeof(arr[0]);
   
      // Function call
    cout << findRepeating(arr, N);
    return 0;
}

Time complexity: linear
Space complexity: constant
// CPP program to find the only repeating
// element in an array where elements are
// from 1 to N-1.
#include <bits/stdc++.h>
using namespace std;
 
int findRepeating(int arr[], int N)
{
 
    // res is going to store value of
    // 1 ^ 2 ^ 3 .. ^ (N-1) ^ arr[0] ^
    // arr[1] ^ .... arr[N-1]
    int res = 0;
    for (int i = 0; i < N - 1; i++)
        res = res ^ (i + 1) ^ arr[i];
    res = res ^ arr[N - 1];
    return res;
}
 
// Driver code
int main()
{
    int arr[] = { 9, 8, 2, 6, 1, 8, 5, 3, 4, 7 };
    int N = sizeof(arr) / sizeof(arr[0]);
   
      // Function call
    cout << findRepeating(arr, N);
    return 0;
}

Time complexity: linear
Space complexity: constant
// CPP program to find the only
// repeating element in an array
// where elements are from 1 to N-1.
 
#include <bits/stdc++.h>
using namespace std;
 
// Function to find repeated element
int findRepeating(int arr[], int N)
{
    int missingElement = 0;
 
    // indexing based
    for (int i = 0; i < N; i++) {
 
        int element = arr[abs(arr[i])];
 
        if (element < 0) {
            missingElement = arr[i];
            break;
        }
 
        arr[abs(arr[i])] = -arr[abs(arr[i])];
    }
 
    return abs(missingElement);
}
 
// Driver code
int main()
{
    int arr[] = { 9, 8, 2, 6, 1, 8, 5, 3, 4, 7 };
 
    int N = sizeof(arr) / sizeof(arr[0]);
 
    // Function call
    cout << findRepeating(arr, N);
 
    return 0;
}

Time complexity: linear
Space complexity: constant
#include <bits/stdc++.h>
using namespace std;
 
int findDuplicate(vector<int>& nums)
{
    int slow = nums[0];
    int fast = nums[0];
 
    do {
        slow = nums[slow];
        fast = nums[nums[fast]];
    } while (slow != fast);
 
    fast = nums[0];
    while (slow != fast) {
        slow = nums[slow];
        fast = nums[fast];
    }
 
    return slow;
}
 
// Driver code
int main()
{
    vector<int> v{ 9, 8, 2, 6, 1, 8, 5, 3, 4, 7 };
   
      // Function call
    int ans = findDuplicate(v);
    cout << ans << endl;
    return 0;
}

Time complexity: linear
Space complexity: constant
// C++ program to find the array element
// that appears only once
 
#include <iostream>
using namespace std;
 
// Function to find the
int findSingle(int A[], int ar_size)
{
 
    // Iterate over every element
    for (int i = 0; i < ar_size; i++) {
 
        // Initialize count to 0
        int count = 0;
 
        for (int j = 0; j < ar_size; j++) {
 
            // Count the frequency
            // of the element
            if (A[i] == A[j]) {
                count++;
            }
        }
 
        // if the frequency of the
        // element is one
        if (count == 1) {
            return A[i];
        }
    }
 
    // if no element exist at most once
    return -1;
}
 
// Driver code
int main()
{
    int ar[] = { 2, 3, 5, 4, 5, 3, 4 };
    int n = sizeof(ar) / sizeof(ar[0]);
   
      // Function call
    cout << "Element occurring once is "
         << findSingle(ar, n);
   
    return 0;
}
 
// This code is contributed by Arpit Jain

Time complexity: quadratic
Space complexity: constant
// C++ program to find the array element
// that appears only once
#include <iostream>
using namespace std;
 
int findSingle(int ar[], int ar_size)
{
    // Do XOR of all elements and return
    int res = ar[0];
    for (int i = 1; i < ar_size; i++)
        res = res ^ ar[i];
 
    return res;
}
 
// Driver code
int main()
{
    int ar[] = { 2, 3, 5, 4, 5, 3, 4 };
    int n = sizeof(ar) / sizeof(ar[0]);
    cout << "Element occurring once is "
         << findSingle(ar, n);
    return 0;
}
 
// This code is contributed by Aditya Kumar (adityakumar129)

Time complexity: linear
Space complexity: constant
// C++ program to find
// element that appears once
#include <bits/stdc++.h>
 
using namespace std;
 
// function which find number
int singleNumber(int nums[],int n)
{
    map<int,int> m;
    long sum1 = 0,sum2 = 0;
 
    for(int i = 0; i < n; i++)
    {
        if(m[nums[i]] == 0)
        {
            sum1 += nums[i];
            m[nums[i]]++;
        }
        sum2 += nums[i];
    }
     
    // applying the formula.
    return 2 * (sum1) - sum2;
}
 
// Driver code
int main()
{
    int a[] = {2, 3, 5, 4, 5, 3, 4};
    int n = 7;
    cout << singleNumber(a,n) << "\n";
 
    int b[] = {15, 18, 16, 18, 16, 15, 89};
 
    cout << singleNumber(b,n);
    return 0;
}
 
// This code is contributed by mohit kumar 29

Time complexity: nlogn
Space complexity: linear
#include <bits/stdc++.h>
using namespace std;
int singleelement(int arr[], int n)
{
    int low = 0, high = n - 2;
    int mid;
    while (low <= high) {
        mid = (low + high) / 2;
        if (arr[mid] == arr[mid ^ 1])
            low = mid + 1;
        else
            high = mid - 1;
    }
    return arr[low];
}
int main()
{
    int arr[] = { 2, 3, 5, 4, 5, 3, 4 };
    int size = sizeof(arr) / sizeof(arr[0]);
    sort(arr, arr + size);
    cout << singleelement(arr, size);
    return 0;
}
 
// This code is contributed by Sania Kumari Gupta

Time complexity: nlogn
Space complexity: constant
// C++ Program to find max subarray
// sum excluding some elements
#include <bits/stdc++.h>
using namespace std;
 
// Function to check the element
// present in array B
bool isPresent(int B[], int m, int x)
{
    for (int i = 0; i < m; i++)
        if (B[i] == x)
            return true;
    return false;
}
 
// Utility function for findMaxSubarraySum()
// with the following parameters
// A => Array A,
// B => Array B,
// n => Number of elements in Array A,
// m => Number of elements in Array B
int findMaxSubarraySumUtil(int A[], int B[], int n, int m)
{
 
    // set max_so_far to INT_MIN
    int max_so_far = INT_MIN, curr_max = 0;
 
    for (int i = 0; i < n; i++)
    {
        // if the element is present in B,
        // set current max to 0 and move to
        // the next element */
        if (isPresent(B, m, A[i]))
        {
            curr_max = 0;
            continue;
        }
 
        // Proceed as in Kadane's Algorithm
        curr_max = max(A[i], curr_max + A[i]);
        max_so_far = max(max_so_far, curr_max);
    }
    return max_so_far;
}
 
// Wrapper for findMaxSubarraySumUtil()
void findMaxSubarraySum(int A[], int B[], int n, int m)
{
    int maxSubarraySum = findMaxSubarraySumUtil(A, B, n, m);
 
    // This case will occur when all elements
    // of A are present in B, thus
    // no subarray can be formed
    if (maxSubarraySum == INT_MIN)
    {
        cout << "Maximum Subarray Sum cant be found"
             << endl;
    }
    else
    {
        cout << "The Maximum Subarray Sum = "
             << maxSubarraySum << endl;
    }
}
 
// Driver Code
int main()
{
    int A[] = { 3, 4, 5, -4, 6 };
    int B[] = { 1, 8, 5 };
 
    int n = sizeof(A) / sizeof(A[0]);
    int m = sizeof(B) / sizeof(B[0]);
 
    // Function call
    findMaxSubarraySum(A, B, n, m);
 
    return 0;
}

Time complexity: quadratic
Space complexity: constant
// C++ Program to find max subarray
// sum excluding some elements
#include <bits/stdc++.h>
using namespace std;
 
// Utility function for findMaxSubarraySum()
// with the following parameters
// A => Array A,
// B => Array B,
// n => Number of elements in Array A,
// m => Number of elements in Array B
int findMaxSubarraySumUtil(int A[], int B[], int n, int m)
{
 
    // set max_so_far to INT_MIN
    int max_so_far = INT_MIN, curr_max = 0;
 
    for (int i = 0; i < n; i++) {
 
        // if the element is present in B,
        // set current max to 0 and move to
        // the next element
        if (binary_search(B, B + m, A[i])) {
            curr_max = 0;
            continue;
        }
 
        // Proceed as in Kadane's Algorithm
        curr_max = max(A[i], curr_max + A[i]);
        max_so_far = max(max_so_far, curr_max);
    }
    return max_so_far;
}
 
// Wrapper for findMaxSubarraySumUtil()
void findMaxSubarraySum(int A[], int B[], int n, int m)
{
    // sort array B to apply Binary Search
    sort(B, B + m);
 
    int maxSubarraySum = findMaxSubarraySumUtil(A, B, n, m);
 
    // This case will occur when all elements
    // of A are present in B, thus no subarray
    // can be formed
    if (maxSubarraySum == INT_MIN) {
        cout << "Maximum subarray sum cant be found"
             << endl;
    }
    else {
        cout << "The Maximum subarray sum = "
             << maxSubarraySum << endl;
    }
}
 
// Driver Code
int main()
{
    int A[] = { 3, 4, 5, -4, 6 };
    int B[] = { 1, 8, 5 };
 
    int n = sizeof(A) / sizeof(A[0]);
    int m = sizeof(B) / sizeof(B[0]);
 
    // Function call
    findMaxSubarraySum(A, B, n, m);
    return 0;
}

Time complexity: nlogn
Space complexity: constant
// C++ Program implementation of the
// above idea
 
#include<bits/stdc++.h>
using namespace std;
 
// Function to calculate the max sum of contiguous
// subarray of B whose elements are not present in A
int findMaxSubarraySum(vector<int> A,vector<int> B)
{
    unordered_map<int,int> m;
   
    // mark all the elements present in B
    for(int i=0;i<B.size();i++)
    {
        m[B[i]]=1;
    }
     
    // initialize max_so_far with INT_MIN
    int max_so_far=INT_MIN;
    int currmax=0;
    
    // traverse the array A
    for(int i=0;i<A.size();i++)
    {
        if(currmax<0 || m[A[i]]==1)
        {
            currmax=0;
            continue;
        }
         
        currmax=max(A[i],A[i]+currmax);
       
        // if current max is greater than
        // max so far then update max so far
        if(max_so_far<currmax)
        {
            max_so_far=currmax;
        }
    }
    return max_so_far;
}
 
// Driver Code
int main()
{
    vector<int> a = { 3, 4, 5, -4, 6 };
    vector<int> b = { 1, 8, 5 };
  
    // Function call
    cout << findMaxSubarraySum(a,b);
    return 0;
}
 
//This code is contributed by G.Vivek

Time complexity: linear
Space complexity: linear
// CPP program to find
// maximum equilibrium sum.
#include <bits/stdc++.h>
using namespace std;
 
// Function to find
// maximum equilibrium sum.
int findMaxSum(int arr[], int n)
{
    int res = INT_MIN;
    for (int i = 0; i < n; i++)
    {
    int prefix_sum = arr[i];
    for (int j = 0; j < i; j++)
        prefix_sum += arr[j];
 
    int suffix_sum = arr[i];
    for (int j = n - 1; j > i; j--)
        suffix_sum += arr[j];
 
    if (prefix_sum == suffix_sum)
        res = max(res, prefix_sum);
    }
    return res;
}
 
// Driver Code
int main()
{
    int arr[] = {-2, 5, 3, 1,
                  2, 6, -4, 2 };
    int n = sizeof(arr) / sizeof(arr[0]);
    cout << findMaxSum(arr, n);
    return 0;
}

Time complexity: quadratic
Space complexity: linear
// CPP program to find
// maximum equilibrium sum.
#include <bits/stdc++.h>
using namespace std;
 
// Function to find maximum
// equilibrium sum.
int findMaxSum(int arr[], int n)
{
    // Array to store prefix sum.
    int preSum[n];
 
    // Array to store suffix sum.
    int suffSum[n];
 
    // Variable to store maximum sum.
    int ans = INT_MIN;
 
    // Calculate prefix sum.
    preSum[0] = arr[0];
    for (int i = 1; i < n; i++)
        preSum[i] = preSum[i - 1] + arr[i];
 
    // Calculate suffix sum and compare
    // it with prefix sum. Update ans
    // accordingly.
    suffSum[n - 1] = arr[n - 1];
    if (preSum[n - 1] == suffSum[n - 1])
        ans = max(ans, preSum[n - 1]);
         
    for (int i = n - 2; i >= 0; i--)
    {
        suffSum[i] = suffSum[i + 1] + arr[i];
        if (suffSum[i] == preSum[i])
            ans = max(ans, preSum[i]);    
    }
 
    return ans;
}
 
// Driver Code
int main()
{
    int arr[] = { -2, 5, 3, 1,
                   2, 6, -4, 2 };
    int n = sizeof(arr) / sizeof(arr[0]);
    cout << findMaxSum(arr, n);
    return 0;
}

Time complexity: linear
Space complexity: linear
// CPP program to find
// maximum equilibrium sum.
#include <bits/stdc++.h>
using namespace std;
 
// Function to find
// maximum equilibrium sum.
int findMaxSum(int arr[], int n)
{
    int sum = accumulate(arr, arr + n, 0);
    int prefix_sum = 0, res = INT_MIN;
    for (int i = 0; i < n; i++)
    {
    prefix_sum += arr[i];
    if (prefix_sum == sum)
        res = max(res, prefix_sum);
    sum -= arr[i];
    }
    return res;
}
 
// Driver Code
int main()
{
    int arr[] = { -2, 5, 3, 1,
                   2, 6, -4, 2 };
    int n = sizeof(arr) / sizeof(arr[0]);
    cout << findMaxSum(arr, n);
    return 0;
}

Time complexity: linear
Space complexity: constant
// C++ program to find equilibrium
// index of an array
#include <bits/stdc++.h>
using namespace std;
 
int equilibrium(int arr[], int n)
{
    int i, j;
    int leftsum, rightsum;
 
    /* Check for indexes one by one until
    an equilibrium index is found */
    for (i = 0; i < n; ++i) {
 
        /* get left sum */
        leftsum = 0;
        for (j = 0; j < i; j++)
            leftsum += arr[j];
 
        /* get right sum */
        rightsum = 0;
        for (j = i + 1; j < n; j++)
            rightsum += arr[j];
 
        /* if leftsum and rightsum
        are same, then we are done */
        if (leftsum == rightsum)
            return i;
    }
 
    /* return -1 if no equilibrium
    index is found */
    return -1;
}
 
// Driver code
int main()
{
    int arr[] = { -7, 1, 5, 2, -4, 3, 0 };
    int arr_size = sizeof(arr) / sizeof(arr[0]);
 
    // Function call
    cout << equilibrium(arr, arr_size);
    return 0;
}
 
// This code is contributed
// by Akanksha Rai(Abby_akku)

Time complexity: quadratic
Space complexity: constant
// C++ program to find equilibrium
// index of an array
#include <bits/stdc++.h>
using namespace std;
 
int equilibrium(int arr[], int n)
{
    int sum = 0; // initialize sum of whole array
    int leftsum = 0; // initialize leftsum
 
    /* Find sum of the whole array */
    for (int i = 0; i < n; ++i)
        sum += arr[i];
 
    for (int i = 0; i < n; ++i) {
        sum -= arr[i]; // sum is now right sum for index i
 
        if (leftsum == sum)
            return i;
 
        leftsum += arr[i];
    }
 
    /* If no equilibrium index found, then return 0 */
    return -1;
}
 
// Driver code
int main()
{
    int arr[] = { -7, 1, 5, 2, -4, 3, 0 };
    int arr_size = sizeof(arr) / sizeof(arr[0]);
 
    // Function call
    cout << "First equilibrium index is "
         << equilibrium(arr, arr_size);
    return 0;
}
 
// This is code is contributed by rathbhupendra

Time complexity: linear
Space complexity: constant
// C++ program to find equilibrium index of an array
#include <bits/stdc++.h>
using namespace std;
 
int equilibrium(int a[], int n)
{
    if (n == 1)
        return (0);
    int forward[n] = { 0 };
    int rev[n] = { 0 };
 
    // Taking the prefixsum from front end array
    for (int i = 0; i < n; i++) {
        if (i) {
            forward[i] = forward[i - 1] + a[i];
        }
        else {
            forward[i] = a[i];
        }
    }
 
    // Taking the prefixsum from back end of array
    for (int i = n - 1; i > 0; i--) {
        if (i <= n - 2) {
            rev[i] = rev[i + 1] + a[i];
        }
        else {
            rev[i] = a[i];
        }
    }
 
    // Checking if forward prefix sum
    // is equal to rev prefix
    // sum
    for (int i = 0; i < n; i++) {
        if (forward[i] == rev[i]) {
            return i;
        }
    }
    return -1;
 
    // If You want all the points
    // of equilibrium create
    // vector and push all equilibrium
    // points in it and
    // return the vector
}
 
// Driver code
int main()
{
    int arr[] = { -7, 1, 5, 2, -4, 3, 0 };
    int n = sizeof(arr) / sizeof(arr[0]);
 
    // Function call
    cout << "First Point of equilibrium is at index "
         << equilibrium(arr, n) << "\n";
    return 0;
}

Time complexity: linear
Space complexity: linear
#include<iostream>
using namespace std;
 
/*C++ Function to print leaders in an array */
void printLeaders(int arr[], int size)
{
    for (int i = 0; i < size; i++)
    {
        int j;
        for (j = i+1; j < size; j++)
        {
            if (arr[i] <=arr[j])
                break;
        }   
        if (j == size) // the loop didn't break
            cout << arr[i] << " ";
  }
}
 
/* Driver program to test above function */
int main()
{
    int arr[] = {16, 17, 4, 3, 5, 2};
    int n = sizeof(arr)/sizeof(arr[0]);
    printLeaders(arr, n);
    return 0;
}

Time complexity: quadratic
Space complexity: constant
#include <iostream>
using namespace std;
 
/* C++ Function to print leaders in an array */
void printLeaders(int arr[], int size)
{
    int max_from_right =  arr[size-1];
 
    /* Rightmost element is always leader */
    cout << max_from_right << " ";
     
    for (int i = size-2; i >= 0; i--)
    {
        if (max_from_right < arr[i])
        {          
            max_from_right = arr[i];
            cout << max_from_right << " ";
        }
    }   
}
 
/* Driver program to test above function*/
int main()
{
    int arr[] = {16, 17, 4, 3, 5, 2};
    int n = sizeof(arr)/sizeof(arr[0]);
    printLeaders(arr, n);
    return 0;
}   

Time complexity: linear
Space complexity: constant
#include <bits/stdc++.h>
using namespace std;
   
/* C++ Function to print leaders in an array */
void printLeaders(int arr[], int size)
{
      /* create stack to store leaders*/
      stack<int> sk;
      sk.push(arr[size-1]);
     
    for (int i = size-2; i >= 0; i--)
    {
        if(arr[i] >= sk.top())
        {         
            sk.push(arr[i]);
        }
    }  
     
      /* print stack elements*/
      /* run loop till stack is not empty*/
      while(!sk.empty()){     
        cout<<sk.top()<<" ";
          sk.pop();
    }
}
   
/* Driver program to test above function*/
int main()
{
    int arr[] = {16, 17, 4, 3, 5, 2};
    int n = sizeof(arr)/sizeof(arr[0]);
    printLeaders(arr, n);
    return 0;
}

Time complexity: linear
Space complexity: linear
// C++ implementation of above approach
#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 i;
     
    /* If x is smaller than or equal to first element,
        then return the first element */
    if(x <= arr[low])
        return low;
     
    /* Otherwise, linearly search for ceil value */
    for(i = low; i < high; i++)
    {
        if(arr[i] == x)
        return i;
     
        /* if x lies between arr[i] and arr[i+1] including
        arr[i+1], then return arr[i+1] */
        if(arr[i] < x && arr[i+1] >= x)
        return i+1;
    }    
     
    /* If we reach here then x is greater than the last element
        of the array, return -1 in this case */
    return -1;
}
 
 
/* Driver code*/
int main()
{
    int arr[] = {1, 2, 8, 10, 10, 12, 19};
    int n = sizeof(arr)/sizeof(arr[0]);
    int x = 3;
    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 is code is contributed by rathbhupendra

Time complexity: linear
Space complexity: constant