title: Number Visible Boxes Putting One Inside Another
signature: class Solution {
  
      public Integer numberVisibleBoxesPuttingOneInsideAnother(ArrayList<Integer> arr, Integer n) {
source_py: def number_visible_boxes_putting_one_inside_another(arr, n):
      q = collections.deque([])
      arr.sort()
      q.append(arr[0])
      for i in range(1, n):
          now = q[0]
          if (arr[i] >= (2 * now)):
              q.popleft()
          q.append(arr[i])
      return len(q)
source_cpp: int number_visible_boxes_putting_one_inside_another(vector<int> arr, int n) {
    queue < int > q;
    sort(arr.begin(), arr.end());
    q . push ( arr [ 0 ] );
    for ( int i = 1;
    i < n;
    i ++ ) {
      int now = q . front ( );
      if ( arr [ i ] >= 2 * now ) q . pop ( );
      q . push ( arr [ i ] );
    }
    return q . size ( );
  }
question_info.extension: java
question_info.entry_fn_name: numberVisibleBoxesPuttingOneInsideAnother
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 7, "inputs": {"arr": [2, 3, 17, 17, 18, 28, 28, 29, 34, 43, 44, 52, 54, 80, 84, 84, 91, 92, 97], "n": 12}}, {"idx": 1, "outputs": 2, "inputs": {"arr": [-94, -90, -90, -78, -34, -26, -10, 4, 24, 28, 64, 70, 72, 74, 80, 82], "n": 10}}, {"idx": 2, "outputs": 15, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1], "n": 40}}, {"idx": 3, "outputs": 3, "inputs": {"arr": [2, 3, 5, 8, 12, 16, 20, 30, 37, 53, 55, 62, 76, 81, 83, 87, 88, 96], "n": 9}}, {"idx": 4, "outputs": 4, "inputs": {"arr": [-94, -92, -60, -58, -54, -42, -36, -12, -8, -2, 8, 14, 18, 20, 26, 32, 38, 56, 58, 60, 70, 78, 80, 86, 98], "n": 18}}, {"idx": 5, "outputs": 4, "inputs": {"arr": [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 9}}, {"idx": 6, "outputs": 13, "inputs": {"arr": [1, 1, 2, 3, 3, 11, 16, 18, 19, 21, 21, 22, 22, 24, 27, 28, 29, 43, 43, 52, 55, 57, 60, 62, 62, 63, 65, 66, 70, 70, 73, 77, 78, 79, 79, 80, 85, 85, 86, 88, 89, 90, 97, 98], "n": 30}}, {"idx": 7, "outputs": 1, "inputs": {"arr": [-94, -82, -80, -78, -68, -60, -58, -44, -44, -42, -30, -30, -22, -18, -18, -14, -14, -10, -8, -6, 4, 4, 6, 12, 12, 14, 18, 30, 44, 48, 50, 52, 54, 80, 86, 88, 88], "n": 21}}, {"idx": 8, "outputs": 3, "inputs": {"arr": [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 7}}, {"idx": 9, "outputs": 17, "inputs": {"arr": [3, 5, 5, 10, 12, 16, 22, 31, 31, 32, 39, 43, 43, 47, 49, 50, 51, 52, 52, 56, 59, 59, 62, 69, 69, 71, 75, 81, 82, 83, 83, 86, 89, 90, 90, 96], "n": 28}}]
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> arr, Integer n, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(arr, n,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, 3, 17, 17, 18, 28, 28, 29, 34, 43, 44, 52, 54, 80, 84, 84, 91, 92, 97)), 12, 7);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-94, -90, -90, -78, -34, -26, -10, 4, 24, 28, 64, 70, 72, 74, 80, 82)), 10, 2);
          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, 0, 0, 0, 0, 0, 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, 1)), 40, 15);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(2, 3, 5, 8, 12, 16, 20, 30, 37, 53, 55, 62, 76, 81, 83, 87, 88, 96)), 9, 3);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-94, -92, -60, -58, -54, -42, -36, -12, -8, -2, 8, 14, 18, 20, 26, 32, 38, 56, 58, 60, 70, 78, 80, 86, 98)), 18, 4);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 9, 4);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(1, 1, 2, 3, 3, 11, 16, 18, 19, 21, 21, 22, 22, 24, 27, 28, 29, 43, 43, 52, 55, 57, 60, 62, 62, 63, 65, 66, 70, 70, 73, 77, 78, 79, 79, 80, 85, 85, 86, 88, 89, 90, 97, 98)), 30, 13);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-94, -82, -80, -78, -68, -60, -58, -44, -44, -42, -30, -30, -22, -18, -18, -14, -14, -10, -8, -6, 4, 4, 6, 12, 12, 14, 18, 30, 44, 48, 50, 52, 54, 80, 86, 88, 88)), 21, 1);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 7, 3);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(3, 5, 5, 10, 12, 16, 22, 31, 31, 32, 39, 43, 43, 47, 49, 50, 51, 52, 52, 56, 59, 59, 62, 69, 69, 71, 75, 81, 82, 83, 83, 86, 89, 90, 90, 96)), 28, 17);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(ArrayList<Integer> arr, Integer n, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(arr, n),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__