title: java arrays finding duplicates and replacing them
body: <pre><code>public static int[] isthereDuplicates(int[] combination) {
      Set&lt;Integer&gt; foundedNumbers = new HashSet&lt;&gt;();
  
      for (int i= 0; index &lt; combination.length; i++) {
          if (foundedNumbers.contains(combination[i])) {
                  combination[i] -= 1;
          } else {
              foundedNumbers.add(combination[i]);
          }
  
      return combination;
  }
  </code></pre>
  
  <p>i need to find and replace duplicates in an array of numbers. number array is also made  with random selection of 7  numbers between 1 and 40.This code that i presented works if i have one duplicate  but when i have several for example i have 1,14,20,1,38,1,5. it will change for middle 1 but for second 1 it will remain the same.</p>