## Amazon Interview Question for Quality Assurance Engineers

Country: India
Interview Type: Written Test

Comment hidden because of low score. Click to expand.
0
of 0 vote

Make hash table of S1. Iterate S1 if all elements are present and iterate S3 if any one element is missing by checking with hash table of S1.

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````import java.util.HashMap;
import java.util.Map;

public class SubSetQuestion {

public static void main(String[] args) {
int[] S1 = {1,5,4,6,8,2};
int[] S2 = {5,8,2};
int[] S3 = {5,8,2,7};

Map<Integer, Integer> map = new HashMap();
for(int i=0;i<S1.length;i++)
{
map.put(S1[i], 1);
}

for(int i=0;i<S2.length;i++)
{
if(!map.containsKey(S2[i]))
System.out.println("S2 is not subset");
}

for(int i=0;i<S3.length;i++)
{
if(!map.containsKey(S3[i]))
System.out.println("S3 is not subset");
}

}

}``````

Comment hidden because of low score. Click to expand.
0

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void findSubset(){
int s1[]={1,5,4,6,8,2};
int s2[]={5,8,2};
//int s2[]={5,8,2,7};

if(s2.length > s1.length || s2.length == 0)
System.out.println(s2+" is not a subset of "+s1);

int k=0;
boolean isSubset=false;
for(int i=0;i<s1.length;i++){
if(s1[i] == s2[k]){
if(k+1 == s2.length){
System.out.println(s2+" is a subset of "+s1);
isSubset=true;
}
k++;
}
}
if(!isSubset)
System.out.println(s2+" is not a subset of "+s1);

}``````

Comment hidden because of low score. Click to expand.
0

This would not work for inputs like :
s1[]={5,4,6,8,2};
s2[]={8,5,2};

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void findSubset(){
int s1[]={1,5,4,6,8,2};
int s2[]={5,8,2};
//int s2[]={5,8,2,7};

if(s2.length > s1.length || s2.length == 0)
System.out.println(s2+" is not a subset of "+s1);

int k=0;
boolean isSubset=false;
for(int i=0;i<s1.length;i++){
if(s1[i] == s2[k]){
if(k+1 == s2.length){
System.out.println(s2+" is a subset of "+s1);
isSubset=true;
}
k++;
}
}
if(!isSubset)
System.out.println(s2+" is not a subset of "+s1);

}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void findSubset(){
int s1[]={1,5,4,6,8,2};
int s2[]={5,8,2};
//int s2[]={5,8,2,7};

if(s2.length > s1.length || s2.length == 0)
System.out.println(s2+" is not a subset of "+s1);

int k=0;
boolean isSubset=false;
for(int i=0;i<s1.length;i++){
if(s1[i] == s2[k]){
if(k+1 == s2.length){
System.out.println(s2+" is a subset of "+s1);
isSubset=true;
}
k++;
}
}
if(!isSubset)
System.out.println(s2+" is not a subset of "+s1);``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void findSubset(){
int s1[]={1,5,4,6,8,2};
int s2[]={5,8,2};
//int s2[]={5,8,2,7};

if(s2.length > s1.length || s2.length == 0)
System.out.println(s2+" is not a subset of "+s1);

int k=0;
boolean isSubset=false;
for(int i=0;i<s1.length;i++){
if(s1[i] == s2[k]){
if(k+1 == s2.length){
System.out.println(s2+" is a subset of "+s1);
isSubset=true;
}
k++;
}
}
if(!isSubset)
System.out.println(s2+" is not a subset of "+s1);

}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

For this above problem, one may use unordered set in c++ and insert all the elements of s1 to the set and then keep traversing both the other arrays and check that for the s2 array if all the elements are present and for the s3 array all the elements are not present then return true else return false.

Implementation:

#include<bits/stdc++.h>
using namespace std;
bool findsubsets(int s1[], int n1, int s2[], int n2, int s3[], int n3){
int flag = 0;
int temp = 0;
unordered_set<int> s;
for(int i = 0; i < n1; i++)
s.insert(s1[i]);
for(int j = 0; j < n2; j++){
if(s.find(s2[j]) == s.end()){
flag = -1;
break;
}
}
if(flag != -1)
flag = 1;
for(int j = 0; j < n3; j++){
if(s.find(s3[j]) == s.end()){
temp = 1;
break;
}
}
if(temp != 1)
temp = -1;
if(flag == 1 && temp == 1)
return true;
else
return false;
}
int main()
{
int s1[] = {1, 5, 4, 6, 8, 2};
int s2[] = {5, 8, 2};
int s3[] = {5, 8, 2, 7};
int n1 = sizeof(s1) / sizeof(s1[0]);
int n2 = sizeof(s2) / sizeof(s2[0]);
int n3 = sizeof(s3) / sizeof(s3[0]);
cout<<findsubsets(s1, n1, s2, n2, s3, n3)<<endl;

return 0;
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

public class Subset {

public static void main(String args[]) {

int[] s2 = {5, 8, 2};
int[] s1 = {1, 5, 4, 6, 8, 2};
int[] s3 = {5, 8, 2, 7};

Set<Integer> s = new HashSet<Integer>();
for (Integer i : s1) {
}
System.out.println(isContains(s2, s));
System.out.println(isContains(s3, s));
}

private static boolean isContains(int[] array, Set s) {
for (int i : array) {
return false;
}
}
return true;
}
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

package carrercup;

import java.util.*;

public class Subset {

public static void main(String args[]) {
int[] s2 = {5, 8, 2};
int[] s1 = {1, 5, 4, 6, 8, 2};
int[] s3 = {5, 8, 2, 7};

Set<Integer> s = new HashSet<Integer>();
for (Integer i : s1) {
}
System.out.println(isContains(s2, s));
System.out.println(isContains(s3, s));
}

private static boolean isContains(int[] array, Set s) {
for (int i : array) {
return false;
}
}
return true;
}

}

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void checkSubset() {
int[] S1 = {1,5,4,6,8,2};
int[] S2 = {5,8,2};
int[] S3 = {5,8,2,7};

List<Integer> s1List = new ArrayList<Integer>();
for(int s: S1) {
}

List<Integer> s2List = new ArrayList<Integer>();
for(int s: S2) {
}

List<Integer> s3List = new ArrayList<Integer>();
for(int s: S3) {
}

// Finding if S2 is a subset of S1
boolean isSubset = false;
for(int s: s2List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S2 Subset of S1: "+isSubset);

// Finding if S2 is a subset of S1
isSubset = false;
for(int s: s3List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S3 Subset of S1: "+isSubset);``````

}

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void checkSubset() {
int[] S1 = {1,5,4,6,8,2};
int[] S2 = {5,8,2};
int[] S3 = {5,8,2,7};

List<Integer> s1List = new ArrayList<Integer>();
for(int s: S1) {
}

List<Integer> s2List = new ArrayList<Integer>();
for(int s: S2) {
}

List<Integer> s3List = new ArrayList<Integer>();
for(int s: S3) {
}

// Finding if S2 is a subset of S1
boolean isSubset = false;
for(int s: s2List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S2 Subset of S1: "+isSubset);

// Finding if S2 is a subset of S1
isSubset = false;
for(int s: s3List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S3 Subset of S1: "+isSubset);
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void checkSubset() {
int[] S1 = {1,5,4,6,8,2};
int[] S2 = {5,8,2};
int[] S3 = {5,8,2,7};

List<Integer> s1List = new ArrayList<Integer>();
for(int s: S1) {
}

List<Integer> s2List = new ArrayList<Integer>();
for(int s: S2) {
}

List<Integer> s3List = new ArrayList<Integer>();
for(int s: S3) {
}

// Finding if S2 is a subset of S1
boolean isSubset = false;
for(int s: s2List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S2 Subset of S1: "+isSubset);

// Finding if S2 is a subset of S1
isSubset = false;
for(int s: s3List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S3 Subset of S1: "+isSubset);
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void checkSubset() {
int[] S1 = {1,5,4,6,8,2};
int[] S2 = {5,8,2};
int[] S3 = {5,8,2,7};

List<Integer> s1List = new ArrayList<Integer>();
for(int s: S1) {
}

List<Integer> s2List = new ArrayList<Integer>();
for(int s: S2) {
}

List<Integer> s3List = new ArrayList<Integer>();
for(int s: S3) {
}

// Finding if S2 is a subset of S1
boolean isSubset = false;
for(int s: s2List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S2 Subset of S1: "+isSubset);

// Finding if S2 is a subset of S1
isSubset = false;
for(int s: s3List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S3 Subset of S1: "+isSubset);
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void checkSubset() {
int[] S1 = {1,5,4,6,8,2};
int[] S2 = {5,8,2};
int[] S3 = {5,8,2,7};

List<Integer> s1List = new ArrayList<Integer>();
for(int s: S1) {
}

List<Integer> s2List = new ArrayList<Integer>();
for(int s: S2) {
}

List<Integer> s3List = new ArrayList<Integer>();
for(int s: S3) {
}

// Finding if S2 is a subset of S1
boolean isSubset = false;
for(int s: s2List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S2 Subset of S1: "+isSubset);

// Finding if S2 is a subset of S1
isSubset = false;
for(int s: s3List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S3 Subset of S1: "+isSubset);
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void checkSubset() {
int[] S1 = {1,5,4,6,8,2};
int[] S2 = {5,8,2};
int[] S3 = {5,8,2,7};

List<Integer> s1List = new ArrayList<Integer>();
for(int s: S1) {
}

List<Integer> s2List = new ArrayList<Integer>();
for(int s: S2) {
}

List<Integer> s3List = new ArrayList<Integer>();
for(int s: S3) {
}

// Finding if S2 is a subset of S1
boolean isSubset = false;
for(int s: s2List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S2 Subset of S1: "+isSubset);

// Finding if S2 is a subset of S1
isSubset = false;
for(int s: s3List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S3 Subset of S1: "+isSubset);
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void checkSubset() {
int[] S1 = {1,5,4,6,8,2};
int[] S2 = {5,8,2};
int[] S3 = {5,8,2,7};

List<Integer> s1List = new ArrayList<Integer>();
for(int s: S1) {
}

List<Integer> s2List = new ArrayList<Integer>();
for(int s: S2) {
}

List<Integer> s3List = new ArrayList<Integer>();
for(int s: S3) {
}

// Finding if S2 is a subset of S1
boolean isSubset = false;
for(int s: s2List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S2 Subset of S1: "+isSubset);

// Finding if S2 is a subset of S1
isSubset = false;
for(int s: s3List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S3 Subset of S1: "+isSubset);
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void checkSubset() {
int[] S1 = {1,5,4,6,8,2};
int[] S2 = {5,8,2};
int[] S3 = {5,8,2,7};

List<Integer> s1List = new ArrayList<Integer>();
for(int s: S1) {
}

List<Integer> s2List = new ArrayList<Integer>();
for(int s: S2) {
}

List<Integer> s3List = new ArrayList<Integer>();
for(int s: S3) {
}

// Finding if S2 is a subset of S1
boolean isSubset = false;
for(int s: s2List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S2 Subset of S1: "+isSubset);

// Finding if S2 is a subset of S1
isSubset = false;
for(int s: s3List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S3 Subset of S1: "+isSubset);
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void checkSubset() {
int[] S1 = {1,5,4,6,8,2};
int[] S2 = {5,8,2};
int[] S3 = {5,8,2,7};

List<Integer> s1List = new ArrayList<Integer>();
for(int s: S1) {
}

List<Integer> s2List = new ArrayList<Integer>();
for(int s: S2) {
}

List<Integer> s3List = new ArrayList<Integer>();
for(int s: S3) {
}

// Finding if S2 is a subset of S1
boolean isSubset = false;
for(int s: s2List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S2 Subset of S1: "+isSubset);

// Finding if S2 is a subset of S1
isSubset = false;
for(int s: s3List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S3 Subset of S1: "+isSubset);
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void checkSubset() {
int[] S1 = {1,5,4,6,8,2};
int[] S2 = {5,8,2};
int[] S3 = {5,8,2,7};

List<Integer> s1List = new ArrayList<Integer>();
for(int s: S1) {
}

List<Integer> s2List = new ArrayList<Integer>();
for(int s: S2) {
}

List<Integer> s3List = new ArrayList<Integer>();
for(int s: S3) {
}

// Finding if S2 is a subset of S1
boolean isSubset = false;
for(int s: s2List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S2 Subset of S1: "+isSubset);

// Finding if S2 is a subset of S1
isSubset = false;
for(int s: s3List) {

if (s1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
System.out.println("Is S3 Subset of S1: "+isSubset);
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void main(String[] args) {
System.out.println("Hello world!");
ArrayList<Integer> ls2=new ArrayList<>(Arrays.asList(5,8,2));
List ls1=new ArrayList<>(Arrays.asList(1,5,4,6,8,2));
List ls3=new ArrayList<>(Arrays.asList(5,8,2,7));

System.out.println(ls1.containsAll(ls2));
System.out.println(ls2.containsAll(ls3));

}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void main(String[] args) {
System.out.println("Hello world!");
ArrayList<Integer> ls2=new ArrayList<>(Arrays.asList(5,8,2));
List ls1=new ArrayList<>(Arrays.asList(1,5,4,6,8,2));
List ls3=new ArrayList<>(Arrays.asList(5,8,2,7));

System.out.println(ls1.containsAll(ls2));
System.out.println(ls2.containsAll(ls3));

}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void main(String[] args) {
System.out.println("Hello world!");
ArrayList<Integer> ls2=new ArrayList<>(Arrays.asList(5,8,2));
List ls1=new ArrayList<>(Arrays.asList(1,5,4,6,8,2));
List ls3=new ArrayList<>(Arrays.asList(5,8,2,7));

System.out.println(ls1.containsAll(ls2));
System.out.println(ls2.containsAll(ls3));

}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void main(String[] args) {
System.out.println("Hello world!");
ArrayList<Integer> ls2=new ArrayList<>(Arrays.asList(5,8,2));
List ls1=new ArrayList<>(Arrays.asList(1,5,4,6,8,2));
List ls3=new ArrayList<>(Arrays.asList(5,8,2,7));

System.out.println(ls1.containsAll(ls2));
System.out.println(ls2.containsAll(ls3));

}

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static void main(String[] args) {
System.out.println("Hello world!");
ArrayList<Integer> ls2=new ArrayList<>(Arrays.asList(5,8,2));
List ls1=new ArrayList<>(Arrays.asList(1,5,4,6,8,2));
List ls3=new ArrayList<>(Arrays.asList(5,8,2,7));

System.out.println(ls1.containsAll(ls2));
System.out.println(ls2.containsAll(ls3));``````

}

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````import java.util.*;
class Subset {

static boolean isSubset(int[] a, int [] b) {
List<Integer>S1List= new ArrayList<Integer>();
List<Integer>S2List= new ArrayList<Integer>();
for(int s: a ){
}

for(int s:b ){
}

// Finding if S2 is a subset of S1
boolean isSubset = false;
for(int s:S2List) {

if (S1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
return isSubset;
}

public static void main(String[] args) {
int[] S1 = {1,5,4,6,8,2};
int[] S2 = {5,8,2};
int[] S3 = {5,8,2,1};
boolean ret = isSubset(S1, S2);
System.out.println( (ret) ? "S2 is Subset of S1" : "S2 is not Subset of S1" );
boolean ret2 = isSubset(S1, S3);
System.out.println( (ret2) ? "S3 is Subset of S1" : "S3 is not Subset of S1" );

}
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.*;
class Subset {

static boolean isSubset(int[] a, int [] b) {
List<Integer>S1List= new ArrayList<Integer>();
List<Integer>S2List= new ArrayList<Integer>();
for(int s: a ){
}

for(int s:b ){
}

// Finding if S2 is a subset of S1
boolean isSubset = false;
for(int s:S2List) {

if (S1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
return isSubset;
}

public static void main(String[] args) {
int[] S1 = {1,5,4,6,8,2};
int[] S2 = {5,8,2};
int[] S3 = {5,8,2,1};
boolean ret = isSubset(S1, S2);
System.out.println( (ret) ? "S2 is Subset of S1" : "S2 is not Subset of S1" );
boolean ret2 = isSubset(S1, S3);
System.out.println( (ret2) ? "S3 is Subset of S1" : "S3 is not Subset of S1" );

}
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````{import java.util.*;
class Subset {

static boolean isSubset(int[] a, int [] b) {
List<Integer>S1List= new ArrayList<Integer>();
List<Integer>S2List= new ArrayList<Integer>();
for(int s: a ){
}

for(int s:b ){
}

// Finding if S2 is a subset of S1
boolean isSubset = false;
for(int s:S2List) {

if (S1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
return isSubset;
}

public static void main(String[] args) {
int[] S1 = {1,5,4,6,8,2};
int[] S2 = {5,8,2};
int[] S3 = {5,8,2,1};
boolean ret = isSubset(S1, S2);
System.out.println( (ret) ? "S2 is Subset of S1" : "S2 is not Subset of S1" );
boolean ret2 = isSubset(S1, S3);
System.out.println( (ret2) ? "S3 is Subset of S1" : "S3 is not Subset of S1" );

}
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````import java.util.*;
class Subset {

static boolean isSubset(int[] a, int [] b) {
List<Integer>S1List= new ArrayList<Integer>();
List<Integer>S2List= new ArrayList<Integer>();
for(int s: a ){
}

for(int s:b ){
}

// Finding if S2 is a subset of S1
boolean isSubset = false;
for(int s:S2List) {

if (S1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
return isSubset;
}

public static void main(String[] args) {
int[] S1 = {1,5,4,6,8,2};
int[] S2 = {5,8,2};
int[] S3 = {5,8,2,1};
boolean ret = isSubset(S1, S2);
System.out.println( (ret) ? "S2 is Subset of S1" : "S2 is not Subset of S1" );
boolean ret2 = isSubset(S1, S3);
System.out.println( (ret2) ? "S3 is Subset of S1" : "S3 is not Subset of S1" );

}
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.*;
class Subset {

static boolean isSubset(int[] a, int [] b) {
List<Integer>S1List= new ArrayList<Integer>();
List<Integer>S2List= new ArrayList<Integer>();
for(int s: a ){
}

for(int s:b ){
}

// Finding if S2 is a subset of S1
boolean isSubset = false;
for(int s:S2List) {

if (S1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
return isSubset;
}

public static void main(String[] args) {
int[] S1 = {1,5,4,6,8,2};
int[] S2 = {5,8,2};
int[] S3 = {5,8,2,1};
boolean ret = isSubset(S1, S2);
System.out.println( (ret) ? "S2 is Subset of S1" : "S2 is not Subset of S1" );
boolean ret2 = isSubset(S1, S3);
System.out.println( (ret2) ? "S3 is Subset of S1" : "S3 is not Subset of S1" );

}
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````import java.util.*;
class Subset {

static boolean isSubset(int[] a, int [] b) {
List<Integer>S1List= new ArrayList<Integer>();
List<Integer>S2List= new ArrayList<Integer>();
for(int s: a ){
}

for(int s:b ){
}

// Finding if S2 is a subset of S1
boolean isSubset = false;
for(int s:S2List) {

if (S1List.contains(s)) {
isSubset = true;
}
else {
isSubset = false;
break;
}
}
return isSubset;
}

public static void main(String[] args) {
int[] S1 = {1,5,4,6,8,2};
int[] S2 = {5,8,2};
int[] S3 = {5,8,2,1};
boolean ret = isSubset(S1, S2);
System.out.println( (ret) ? "S2 is Subset of S1" : "S2 is not Subset of S1" );
boolean ret2 = isSubset(S1, S3);
System.out.println( (ret2) ? "S3 is Subset of S1" : "S3 is not Subset of S1" );

}
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````public static boolean verifySubSetOrNot(int[] superSetval, int[] subSetval) {
Map<Integer, Integer> superSetMap = new HashMap<Integer, Integer>();
boolean isSubsetPresent = false;

for (int i = 0; i <= superSetval.length - 1; i++) {
superSetMap.put(i, superSetval[i]);
}

for (int j = 0; j <= subSetval.length - 1; j++) {
if (!superSetMap.containsValue(subSetval[j])) {
isSubsetPresent = false;
} else {
isSubsetPresent = true;
}
}
return isSubsetPresent;``````

}

Comment hidden because of low score. Click to expand.
0
of 0 vote

def isSubSet(set_x, set_y): # O(n)
_isSubSet = False
if len(set_x) >= len(set_y):
return _isSubSet
for x in range(len(set_x)-1):
if set_x[x] not in set_y:
return _isSubSet
return True
if __name__ == '__main__':
v = isSubSet([i for i in S2],[j for j in S1])

Comment hidden because of low score. Click to expand.
0
of 0 vote

public static boolean isSubset(int masterArr[], int childArr[]) {

boolean subset = false;

for(int i = 0; i <= childArr.length-1; i++) {

for(int j=0 ; j<= masterArr.length -1 ; j++) {

if((childArr[i] == masterArr[j])) {

subset = true;
}
if(j == childArr.length-1) {
subset = false;
}
}

}

return subset;
}

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.