@Test public void firstTest(){ int groundTruth= iterator.next(2); Assertions.assertEquals(8,groundTruth); }
public int next(int n) { if(n>0){ while(index<len){ if(seq[index]==0){ index+=2; }else if(seq[index]<n){ n=n-seq[index]; index+=2; }else if(seq[index]>=n){ seq[index]=seq[index]-n; return seq[index+1]; } } } return -1; }
RLEIterator { public int next(int n) { if(n>0){ while(index<len){ if(seq[index]==0){ index+=2; }else if(seq[index]<n){ n=n-seq[index]; index+=2; }else if(seq[index]>=n){ seq[index]=seq[index]-n; return seq[index+1]; } } } return -1; } }
RLEIterator { public int next(int n) { if(n>0){ while(index<len){ if(seq[index]==0){ index+=2; }else if(seq[index]<n){ n=n-seq[index]; index+=2; }else if(seq[index]>=n){ seq[index]=seq[index]-n; return seq[index+1]; } } } return -1; } RLEIterator(int[] A); }
RLEIterator { public int next(int n) { if(n>0){ while(index<len){ if(seq[index]==0){ index+=2; }else if(seq[index]<n){ n=n-seq[index]; index+=2; }else if(seq[index]>=n){ seq[index]=seq[index]-n; return seq[index+1]; } } } return -1; } RLEIterator(int[] A); int next(int n); }
RLEIterator { public int next(int n) { if(n>0){ while(index<len){ if(seq[index]==0){ index+=2; }else if(seq[index]<n){ n=n-seq[index]; index+=2; }else if(seq[index]>=n){ seq[index]=seq[index]-n; return seq[index+1]; } } } return -1; } RLEIterator(int[] A); int next(int n);  }