Mahmoud_Hawara

Untitled

Jan 23rd, 2026
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Main {
  4.    
  5.     static boolean subset(int[] a, int[] b) {
  6.         for (int i = 0; i < a.length; i++) {
  7.             boolean found = false;
  8.             for (int j = 0; j < b.length; j++) {
  9.                 if (a[i] == b[j]) {
  10.                     found = true;
  11.                     break;
  12.                 }
  13.             }
  14.             if (found == false) return false;
  15.         }
  16.         return true;
  17.     }
  18.    
  19.     public static void main(String[] args) {
  20.         int[] a = {1, 2, 3};
  21.         int[] b = {2, 4, 5, 1, 3};
  22.         System.out.println(subset(a, b));
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment