title: How to keep zero values in an array of duplicates?
body: <p>I'm still struggling to get the right input for this code where I need to remove duplicates and return the result. I get everything right until this:</p>
  <ul>
  <li><p>given array <code>[100, 0, 3, 4, 4, 562, 100]</code></p>
  </li>
  <li><p>the answer should be <code>[100, 0, 3, 4, 562]</code></p>
  </li>
  <li><p>but what I get is <code>[100, 3, 4, 562]</code> (So it removes the 0)</p>
  </li>
  </ul>
  <p>Is there any way I can just add to my code since I'm not allowed to use any built-in functions, ArrayList, List, Set etc, so just implementing my own solution and functions.</p>
  <pre><code>public static int[] removeDuplicates(int[] input) {
      int[] withoutDubs = new int[input.length];
      int pos = 0;
      for(Integer element: input) {
          if(!checkIfInArray(withoutDubs, element)) {
              withoutDubs[pos] = element;
              pos++;
          }
      }
      int[] result = new int[pos];
      for(int i = 0; i &lt; pos; i++) {
          result[i] = withoutDubs[i];
      }
      return result;
  }
  
  public static boolean checkIfInArray(int[] input, int number) {
      if(input == null) {
          return false;
      }
      for(Integer num: input) {
          if(num == number) {
              return true;
          }
      }
      return false;
  }
  </code></pre>