title: Number Visible Boxes Putting One Inside Another
signature: function numberVisibleBoxesPuttingOneInsideAnother($arr, $n) {
test_code: <?php
  
  
  // SOLUTION CODE 
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function validateSolution($actual, $expected){
      return serialize($actual) == serialize($expected);
  }
  
  function driver($arr, $n, $expected){
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME($arr, $n), $expected)){
          return "PASSED";
        }
        return "FAILED";
      }
      catch (Exception $exception_obj) {
        return get_class($exception_obj);
      }
  }
  
  function main(){
      printf("TEST-0...%s\n",driver(
        array(2, 3, 17, 17, 18, 28, 28, 29, 34, 43, 44, 52, 54, 80, 84, 84, 91, 92, 97), 12, 
        7));
      
      printf("TEST-1...%s\n",driver(
        array(-94, -90, -90, -78, -34, -26, -10, 4, 24, 28, 64, 70, 72, 74, 80, 82), 10, 
        2));
      
      printf("TEST-2...%s\n",driver(
        array(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));
      
      printf("TEST-3...%s\n",driver(
        array(2, 3, 5, 8, 12, 16, 20, 30, 37, 53, 55, 62, 76, 81, 83, 87, 88, 96), 9, 
        3));
      
      printf("TEST-4...%s\n",driver(
        array(-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));
      
      printf("TEST-5...%s\n",driver(
        array(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), 9, 
        4));
      
      printf("TEST-6...%s\n",driver(
        array(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));
      
      printf("TEST-7...%s\n",driver(
        array(-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));
      
      printf("TEST-8...%s\n",driver(
        array(0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1), 7, 
        3));
      
      printf("TEST-9...%s\n",driver(
        array(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));
      
  }
  
  main();
  ?>
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 ( );
  }