#include <bits/stdc++.h>
      using namespace std;
      bool isSubset(int arr1[], int arr2[], int m, int n)
      {
          int i = 0;
          int j = 0;
          for (i = 0; i < n; i++) {
              for (j = 0; j < m; j++) {
                  if (arr2[i] == arr1[j])
                      break;
              }
              if (j == m)
                 return 0;
          }
          return 1;
      }
      // Driver code
      int main()
      {
          int arr1[] = { 11, 10, 13, 21, 30, 70 };
          int arr2[] = { 11, 30, 70, 10 };
          int m = sizeof(arr1) / sizeof(arr1[0]);
          int n = sizeof(arr2) / sizeof(arr2[0]);
          if (isSubset(arr1, arr2, m, n))
              cout<<"arr2[] is subset of arr1[] ";
          else
              cout<<"arr2[] is not a subset of arr1[]";
          return 0;
      }
      
      Cpp language logo

      Program to determine the array is a subset

      0

      0

      avatar
      drzyadav

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.