rahul chaudhary
BAN USER/**
*
*/
package edu.cc.probs;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
* @author RAHULCHA
* Input: two unsorted char arrays A,B(may contain dups) where A.length <= B.length
* If each character in A appears in B, return true. Else false. Write the code.
*/
public class SetProb {
static
{
System.out.println("Mention size of A and B at command line as java SetProb A_arg B_arg");
}
public static void main(String[] args) {
if(args.length!=2)
return;
List<Integer> A=new ArrayList<Integer>();
List<Integer> B=new ArrayList<Integer>();
Scanner sc=new Scanner(System.in);
System.out.println("Filling A");
if((Integer.parseInt(args[0]))>(Integer.parseInt(args[1])))
return;
for(int i=0;i<Integer.parseInt(args[0]);i++){
A.add(sc.nextInt());
}
System.out.println("Filling B");
for(int i=0;i<Integer.parseInt(args[1]);i++){
B.add(sc.nextInt());
}
if(B.containsAll(A)) {
System.out.println("True");
return;
}
else {
System.out.println("False");
System.exit(1);
}
}
}
should be 4
- rahul chaudhary March 30, 2012it should be 4
- rahul chaudhary March 30, 2012
Use Hasmap.keySet() to get all the keys populated in a set and than iterate through it and remove the odd entries ...
- rahul chaudhary October 29, 2012