title: Maximum Height Of Triangular Arrangement Of Array Values 1
signature: pub fn maximum_height_of_triangular_arrangement_of_array_values_1(a: Vec<i32>, n: i32) -> i32 {
test_code: use std::collections::HashMap;
  use std::collections::HashSet;
  use std::cmp::*;
  use std::collections::*;
  use std::fmt::*; 
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  pub fn validate_solution(actual: i32, expected: i32)->bool{
  return actual==expected
  }
  pub fn driver(a: Vec<i32>, n: i32, expected: i32)->String{
      if validate_solution(PLACEHOLDER_FN_NAME(a, n), expected) {
        return "PASSED".to_string();
      };
      return "FAILED".to_string();
  
  }
  
  fn main() {
      println!("TEST-0...{}", driver(
        Vec::from([1, 2, 2, 3, 5, 6, 7, 8, 8, 12, 15, 16, 18, 18, 20, 21, 21, 22, 22, 24, 24, 25, 30, 35, 42, 49, 52, 55, 55, 63, 68, 70, 72, 73, 77, 80, 83, 87, 87, 88, 88, 94, 95, 97]), 22, 
        6
      ));
      
      println!("TEST-1...{}", driver(
        Vec::from([48, -72, 84, -24, 28, 94, 36, 28, 32, 66, -62, 64, 6, -68, -12, 46, 4, 98, 18, 86, -60, 76, 14, 98]), 12, 
        4
      ));
      
      println!("TEST-2...{}", driver(
        Vec::from([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, 1, 1, 1, 1]), 25, 
        6
      ));
      
      println!("TEST-3...{}", driver(
        Vec::from([11, 16, 84, 8, 86, 44, 79, 11, 73, 12, 29, 62, 22, 44, 28, 8, 48, 92, 73, 63, 59, 44, 95, 66]), 14, 
        4
      ));
      
      println!("TEST-4...{}", driver(
        Vec::from([-94, -94, -92, -88, -86, -82, -80, -80, -78, -76, -56, -56, -50, -44, -42, -36, -36, -32, -32, -26, -14, -12, -6, 12, 24, 28, 34, 38, 42, 42, 46, 50, 56, 62, 62, 74, 84, 92, 94]), 19, 
        5
      ));
      
      println!("TEST-5...{}", driver(
        Vec::from([0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0]), 24, 
        6
      ));
      
      println!("TEST-6...{}", driver(
        Vec::from([2, 2, 3, 3, 3, 4, 5, 13, 16, 18, 21, 22, 27, 28, 32, 34, 36, 37, 41, 42, 43, 51, 52, 52, 54, 54, 61, 65, 67, 67, 68, 71, 75, 77, 77, 78, 80, 81, 81, 84, 86, 90, 90, 93, 93, 94, 99, 99]), 31, 
        7
      ));
      
      println!("TEST-7...{}", driver(
        Vec::from([54, -86]), 1, 
        1
      ));
      
      println!("TEST-8...{}", driver(
        Vec::from([0, 1]), 1, 
        1
      ));
      
      println!("TEST-9...{}", driver(
        Vec::from([5, 54, 49, 80, 56, 62, 31, 49, 60, 19, 45, 94, 33, 46, 32]), 8, 
        3
      ));
      
  }
source_py: def maximum_height_of_triangular_arrangement_of_array_values_1(a, n):
      return (((- 1) + int(math.sqrt((1 + (8 * n))))) // 2)
source_cpp: int maximum_height_of_triangular_arrangement_of_array_values_1(vector<int> a, int n) {
    return floor ( ( - 1 + sqrt ( 1 + ( 8 * n ) ) ) / 2 );
  }