title: Maximum Height Of Triangular Arrangement Of Array Values 1
signature: class Solution {
  
      public Integer maximumHeightOfTriangularArrangementOfArrayValues1(ArrayList<Integer> a, Integer n) {
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 expected){
          try{
              Driver driver = new Driver();
              if (driver.run(a, 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(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);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(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);
          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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 25, 6);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(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);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-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);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(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);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(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);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(54, -86)), 1, 1);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 1)), 1, 1);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(5, 54, 49, 80, 56, 62, 31, 49, 60, 19, 45, 94, 33, 46, 32)), 8, 3);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(ArrayList<Integer> a, Integer n, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(a, n),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
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 );
  }