class box{
int l,w,h;
box(int a,int b,int c){
l = a;w = b;h = c;
};
};
bool cmp(box a,box b){
return a.l*a.w<b.l*b.w;
}
class Solution{
public:
/*The function takes an array of heights, width and
length as its 3 arguments where each index i value
determines the height, width, length of the ith box.
Here n is the total no of boxes.*/
int maxHeight(int h[],int w[],int l[],int n)
{
//Your code here
struct box b[(3*n)]={};
int j = 0;
for(int i = 0 ; i< n; ++ i){
b[j++] = box(min(l[i],w[i]),max(l[i],w[i]),h[i]);
b[j++] = box(min(l[i],h[i]),max(l[i],h[i]),w[i]);
b[j++] = box(min(w[i],h[i]),max(w[i],h[i]),l[i]);
}
n*=3;
sort(b,b+n,cmp);
int dp[n];
for(int i = 0 ; i< n; ++ i){
dp[i] = b[i].h;
}
int ans = INT_MIN;
for(int i = 1; i< n; ++ i){
for(int j = 0; j< i; ++ j){
if(b[i].l>b[j].l and b[i].w>b[j].w and dp[i]<dp[j]+b[i].h)
dp[i] = b[i].h+dp[j];
}
ans = max(ans,dp[i]);
}
return ans;
}
};
The code above shows an error that struct variables takes 3 arguments and only 1 given as shown. Please help me out of this. Thanks.
Also please provide some good references from where I could get more idea on these kinds of topics. Like sites from where I could learn these type of hints and secrets of language.