Advertisement
Hiteshw11

Check Subset

Nov 24th, 2024
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.39 KB | Source Code | 0 0
  1. /* Write a function that checks if one set is a subset of another.*/
  2.  
  3.  
  4. void main() {
  5.  Set <int> s1={1,2,3};
  6.  Set <int> s2={1,2,3,4,5};
  7. //  Set <int> s1={1,6};
  8. //  Set <int> s2={1,2,3,4,5};
  9.  print(isSubset(s1,s2));
  10.  
  11. }
  12.  
  13. bool isSubset(Set<int> s1,Set<int> s2)
  14. {
  15.  
  16.   bool a=false;
  17.   if(s2.containsAll(s1))
  18.   {
  19.     a=true;
  20.    
  21.   }
  22.   else
  23.   {
  24.     a=false;
  25.   }
  26.   return a;
  27.  
  28. }
Tags: dart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement