title: Number Visible Boxes Putting One Inside Another
signature: class Solution {
  
      public int NumberVisibleBoxesPuttingOneInsideAnother(List<int> arr, int n) {
test_code: using System;
  using System.Numerics;
  using System.Diagnostics;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Security.Cryptography;
  using System.Web.UI;
  using System.Web.Script.Serialization;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  namespace EvaluatePrediction {
      class TestRunner {
          public bool ValidateSolution(int actual, int expected){
              return new JavaScriptSerializer().Serialize(actual) == new JavaScriptSerializer().Serialize(expected);
          }
  
          public string driver(List<int> arr, int n, int expected){
              try{
                PLACEHOLDER_CLS_NAME solution_cls = new PLACEHOLDER_CLS_NAME();
                int pred_result = solution_cls.PLACEHOLDER_FN_NAME(arr, n); 
                if (ValidateSolution(
                      pred_result,
                      expected)){
                  return "PASSED";
                }
                return "FAILED";
              } 
              catch (Exception exception_obj)
              {
                return exception_obj.GetType().FullName;
              }
          }
          static void Main(string[] args) {
              TestRunner runner = new TestRunner();
              String result;
              result = runner.driver(
                  new List<int>{2, 3, 17, 17, 18, 28, 28, 29, 34, 43, 44, 52, 54, 80, 84, 84, 91, 92, 97}, 12, 
                  7
              );
              Console.WriteLine(string.Format(
                  "TEST-0...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{-94, -90, -90, -78, -34, -26, -10, 4, 24, 28, 64, 70, 72, 74, 80, 82}, 10, 
                  2
              );
              Console.WriteLine(string.Format(
                  "TEST-1...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{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
              );
              Console.WriteLine(string.Format(
                  "TEST-2...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{2, 3, 5, 8, 12, 16, 20, 30, 37, 53, 55, 62, 76, 81, 83, 87, 88, 96}, 9, 
                  3
              );
              Console.WriteLine(string.Format(
                  "TEST-3...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{-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
              );
              Console.WriteLine(string.Format(
                  "TEST-4...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 9, 
                  4
              );
              Console.WriteLine(string.Format(
                  "TEST-5...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{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
              );
              Console.WriteLine(string.Format(
                  "TEST-6...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{-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
              );
              Console.WriteLine(string.Format(
                  "TEST-7...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 7, 
                  3
              );
              Console.WriteLine(string.Format(
                  "TEST-8...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{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
              );
              Console.WriteLine(string.Format(
                  "TEST-9...{0}",
                  result)
              );
          }
      }
  }
  
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 ( );
  }