
PART 1 :

this is the code i have, i have written it in top down dp. i will give you 3 test cases and the 
answer. write a bottom up dp code in the same manner i have written, meaning write a seperate 
function . try and complile the code and give me the final code after you run it on any 
compiler on internet like jdoodle or onlinegdb

code : 
#include <iostream>
using namespace std;

int n_baloons, baloon_array[100];
int dp[1000][1000];

int first_padding_index, last_padding_index;

int solve(int left, int right)
{
  int max_score = 0;

  if (left <= first_padding_index || right >= last_padding_index)
  {
    return 0;
  }
  
if(dp[left][right] != -1)
    {
        return dp[left][right]; 
    }



  for (int i = left; i <= right; i++)
  {

    int left_max_points = solve(left, i - 1);
    int right_max_points = solve(i + 1, right);
 
    int current_baloon_points =0;


    //current_baloon_points = left_max_points + right_max_points;

    if (left - 1 == first_padding_index && right + 1 == last_padding_index)
    {
      current_baloon_points =  baloon_array[i];
    } 
    else
    {
      current_baloon_points =  (baloon_array[left - 1] * baloon_array[right + 1]);
    }
    
    int total_points = left_max_points + right_max_points + current_baloon_points;
    
    max_score = max(max_score, total_points);
    dp[left][right] = max_score;

  }
  return max_score;
}
 Please repeat the request first, then give your response.
user