title: Array Element Moved K Using Single Moves
signature: class Solution {
  
      public Integer arrayElementMovedKUsingSingleMoves(ArrayList<Integer> a, Integer n, Integer k) {
source_py: def array_element_moved_k_using_single_moves(a, n, k):
      if (k >= (n - 1)):
          return n
      best = 0
      times = 0
      for i in range(n):
          if (a[i] > best):
              best = a[i]
              if (i == True):
                  times = 1
          else:
              times += 1
          if (times >= k):
              return best
      return best
source_cpp: int array_element_moved_k_using_single_moves(vector<int> a, int n, int k) {
    if ( k >= n - 1 ) return n;
    int best = 0, times = 0;
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( a [ i ] > best ) {
        best = a [ i ];
        if ( i ) times = 1;
      }
      else times += 1;
      if ( times >= k ) return best;
    }
    return best;
  }
question_info.extension: java
question_info.entry_fn_name: arrayElementMovedKUsingSingleMoves
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 33, "inputs": {"a": [2, 5, 5, 9, 10, 10, 11, 14, 23, 27, 31, 32, 33, 33, 33, 37, 39, 41, 41, 42, 42, 43, 47, 60, 61, 68, 73, 73, 73, 78, 80, 80, 82, 83, 86, 87, 89, 92, 94, 98], "n": 33, "k": 37}}, {"idx": 1, "outputs": 14, "inputs": {"a": [80, -58, 64, 48, -16, 60, -50, -52, 62, -86, -96, 52, 26, -30, 14], "n": 14, "k": 13}}, {"idx": 2, "outputs": 7, "inputs": {"a": [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1], "n": 7, "k": 6}}, {"idx": 3, "outputs": 4, "inputs": {"a": [90, 23, 43, 42, 7, 71, 79], "n": 4, "k": 4}}, {"idx": 4, "outputs": 64, "inputs": {"a": [-96, -96, -90, -84, -68, -64, -56, -56, -50, -50, -48, -46, -28, -18, 0, 0, 6, 32, 32, 34, 42, 42, 46, 50, 50, 52, 64, 64, 70, 76, 84, 88], "n": 28, "k": 21}}, {"idx": 5, "outputs": 1, "inputs": {"a": [1, 1, 1], "n": 1, "k": 2}}, {"idx": 6, "outputs": 14, "inputs": {"a": [2, 9, 15, 19, 26, 29, 42, 45, 46, 47, 55, 60, 60, 61, 62, 64, 68, 69, 74, 79, 96], "n": 14, "k": 17}}, {"idx": 7, "outputs": 26, "inputs": {"a": [-32, 12, 80, 42, 80, 8, 58, -76, -42, -98, 22, -90, -16, -4, -62, -32, 28, 12, 78, -52, -84, 78, 88, -76, -52, 68, -34, -16, -4, 2, -78, -94, -22, 34, 6, -62, 72], "n": 26, "k": 31}}, {"idx": 8, "outputs": 1, "inputs": {"a": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 26, "k": 14}}, {"idx": 9, "outputs": 1, "inputs": {"a": [52, 19], "n": 1, "k": 1}}]
question_info.test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(ArrayList<Integer> a, Integer n, Integer k, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(a, n, k,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(new ArrayList<>(Arrays.asList(2, 5, 5, 9, 10, 10, 11, 14, 23, 27, 31, 32, 33, 33, 33, 37, 39, 41, 41, 42, 42, 43, 47, 60, 61, 68, 73, 73, 73, 78, 80, 80, 82, 83, 86, 87, 89, 92, 94, 98)), 33, 37, 33);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(80, -58, 64, 48, -16, 60, -50, -52, 62, -86, -96, 52, 26, -30, 14)), 14, 13, 14);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1)), 7, 6, 7);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(90, 23, 43, 42, 7, 71, 79)), 4, 4, 4);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-96, -96, -90, -84, -68, -64, -56, -56, -50, -50, -48, -46, -28, -18, 0, 0, 6, 32, 32, 34, 42, 42, 46, 50, 50, 52, 64, 64, 70, 76, 84, 88)), 28, 21, 64);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(1, 1, 1)), 1, 2, 1);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(2, 9, 15, 19, 26, 29, 42, 45, 46, 47, 55, 60, 60, 61, 62, 64, 68, 69, 74, 79, 96)), 14, 17, 14);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-32, 12, 80, 42, 80, 8, 58, -76, -42, -98, 22, -90, -16, -4, -62, -32, 28, 12, 78, -52, -84, 78, 88, -76, -52, 68, -34, -16, -4, 2, -78, -94, -22, 34, 6, -62, 72)), 26, 31, 26);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 26, 14, 1);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(52, 19)), 1, 1, 1);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(ArrayList<Integer> a, Integer n, Integer k, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(a, n, k),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: java __FILENAME__