title: almost increasing sequence java
body: <p>I am trying to write code that determines if is it possible to attain an array of strictly increasing integers by removing only one element from that array. </p>
  
  <p>I have my code working for 16 out of 17 cases but cannot think of a way to neatly rewrite my code so that it accounts for the case of a number being bigger than the one before it as well as smaller than the one after it the way I've written this for loop. Here is my code. The case that this doesn't work for is the array: [1, 2, 3, 4, 3, 6], since it doesn't consider the last 3 in the array as an offender the way my for loop is currently constructed.</p>
  
  <pre><code>boolean almostIncreasingSequence(int[] sequence) {
  
  int offenderPosition = 0;
  int[] arrCopy = Arrays.copyOf(sequence, sequence.length);
  boolean ordered = true;
  
  
  //trying to neatly rewrite this for loop 
  for(int i= 0; i &lt; sequence.length; i++){
      if(i&lt;sequence.length-1){
          for(int j = i+1; j &lt; sequence.length; j++) {
              if(!(sequence[i] &lt; sequence[j])){
                  ordered = false;
                  offenderPosition = i;
              }
          }
      }
      if(i == sequence.length-1){
          if(!(sequence[i] &gt; sequence[i-1])){
              ordered = false;
              offenderPosition = i; 
          }
      }
  
  }
  
  
  if(ordered == false) {
      //remove offender 
      int currentSize = arrCopy.length;
      for(int i = offenderPosition+1;i&lt; currentSize; i++) {
          arrCopy[i-1] = arrCopy[i];
      }
      currentSize--;
  
      //reassign array
      arrCopy = Arrays.copyOf(arrCopy, currentSize);
  
      boolean lastChance = true;
  
      for(int i = 0; i &lt; currentSize-1; i++){
          for(int j = i+1; j &lt; currentSize; j++) {
              if(!(arrCopy[i] &lt; arrCopy[j])){
                  lastChance = false;
              }
          }
      }
      return lastChance;
  }
  else{
      return true;
  }
  </code></pre>
  
  <p>}</p>