title: Comparing products given three seperate lists
body: <p>You are given a list of n products, each with a name, price and weight.</p>
  
  <p>Find out how many duplicates of a product are present within the list. A duplicate is a product with all parameters, equal to some other product.</p>
  
  <p>input is 3 lists</p>
  
  <pre><code>   Name Price Weight
   1. ball 2     1
   2. box  2     2
   3. ball 2     1
   4. ball 2     1
   5. box  2     3
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>    2
  </code></pre>
  
  <p>explanation:</p>
  
  <pre><code>   (1.) is same as (3.) and is also same as (4.) so there is 2... 1-&gt;3 and 1-&gt;4
  </code></pre>
  
  <p>Function Description </p>
  
  <p>numDuplicates has the following parameter(s):</p>
  
  <pre><code>name: string array of size n, where names[i] denotes the name of the ith product
  
  price: int array of size n, where prices[i] denotes the price of the ith product
  
  weight: int array of size n, where weights[i] denotes the weight of the ith product
  </code></pre>
  
  <p>function you need to fill out:</p>
  
  <pre><code>public static int numDuplicates(List&lt;String&gt; name, List&lt;Integer&gt; price, List&lt;Integer&gt; weight) {
  // Write your code here
      //return an int
  }
  </code></pre>
  
  <p>this is what i wrote for my code and is O(n^2) but some test-cases are running out of time so i think it wants an O(n) solution but i cant think of it...</p>
  
  <pre><code> class Result {
  
  /*
   * Complete the 'numDuplicates' function below.
   *
   * The function is expected to return an INTEGER.
   * The function accepts following parameters:
   *  1. STRING_ARRAY name
   *  2. INTEGER_ARRAY price
   *  3. INTEGER_ARRAY weight
   */
  
      public static int numDuplicates(List&lt;String&gt; name, List&lt;Integer&gt; price, List&lt;Integer&gt; weight) {
      int count = 0;
      List&lt;obj&gt; classList = new ArrayList&lt;obj&gt;();
      for(int i=0; i&lt;name.size(); i++){
          obj holder = new obj(name.get(i),price.get(i),weight.get(i));
          classList.add(holder);
      }
      for(int i=0; i&lt;classList.size(); i++){
          for(int j=i+1; j&lt;classList.size();j++){
              if(classList.get(i).isDuplicate(classList.get(j))){
                  count++;
                  classList.remove(classList.get(j));
                  j--;
              }
          }
      }
      return count;
   }
  
  }
  
  class obj{
    String name;
    int price;
    int weight;
    public obj(String name, int price, int weight){
        this.name = name;
        this.price = price;
        this.weight = weight;
    }
    public boolean isDuplicate(obj x){
        if(this.name.equals(x.name) &amp;&amp; this.price == x.price &amp;&amp; this.weight == x.weight){
            return true;
        }
        return false;
     }
  }
  </code></pre>
  
  <p>i created my own object class, and i created a compare method but i think it might be inefficent</p>