title: Find Maximum Height Pyramid From The Given Array Of Objects
signature: findMaximumHeightPyramidFromTheGivenArrayOfObjects(boxes, n) {
source_py: def find_maximum_height_pyramid_from_the_given_array_of_objects(boxes, n):
      boxes.sort()
      ans = 1
      prev_width = boxes[0]
      prev_count = 1
      curr_count = 0
      curr_width = 0
      for i in range(1, n):
          curr_width += boxes[i]
          curr_count += 1
          if ((curr_width > prev_width) and (curr_count > prev_count)):
              prev_width = curr_width
              prev_count = curr_count
              curr_count = 0
              curr_width = 0
              ans += 1
      return ans
source_cpp: int find_maximum_height_pyramid_from_the_given_array_of_objects(vector<int> boxes, int n) {
    sort(boxes.begin(), boxes.end());
    int ans = 1;
    int prev_width = boxes [ 0 ];
    int prev_count = 1;
    int curr_count = 0;
    int curr_width = 0;
    for ( int i = 1;
    i < n;
    i ++ ) {
      curr_width += boxes [ i ];
      curr_count += 1;
      if ( curr_width > prev_width && curr_count > prev_count ) {
        prev_width = curr_width;
        prev_count = curr_count;
        curr_count = 0;
        curr_width = 0;
        ans ++;
      }
    }
    return ans;
  }