bro formula for volume u calculated in here is different from which u implemented in the code , in the code u implemented volume=l^2 *(p/4)-(2*l); which i could n't find in here 5:40
Bro pls help it is getting stuck at 1110 test case I dont know whats the problem... // User function Template for Java class Solution { double maxVolume(double perimeter, double area) { // code here double h=(perimeter/2-Math.sqrt(perimeter*perimeter/4-6*area))/6; double v=h*area/2-h*h*perimeter/4+h*h*h; return v; } }
bro formula for volume u calculated in here is different from which u implemented in the code , in the code u implemented volume=l^2 *(p/4)-(2*l);
which i could n't find in here 5:40
why are you caculating twice
perimeter - (sqrt(pow(perimeter, 2) - (24 * area)))) / 12,
Please try to upload cleaner code
You can create one variable and use it once as well
No problem in that too
also tried to code based on given volume formula but it was failing for big test case
your code logic seems different ...
No it's exactly same
Same problem...me doing in Java...it is getting stuck at 1110
Bro pls help it is getting stuck at 1110 test case I dont know whats the problem...
// User function Template for Java
class Solution {
double maxVolume(double perimeter, double area) {
// code here
double h=(perimeter/2-Math.sqrt(perimeter*perimeter/4-6*area))/6;
double v=h*area/2-h*h*perimeter/4+h*h*h;
return v;
}
}
Here is my code which is easy to Understand:
double l = (p - sqrt((p * p) - (24 * a))) / 12;
double ans = (l * l) * ((p / 4) - (2 * l));
return ans;
could you explain how we got this formula as the original formula explained in the video was AL/2 -PL^2/4+L^3
@@AbhieramBandaru simplifying equations
yeh math ka question tha ya coding ka
Math
ans at 110 coming 1131004.73 but my output comes out to be 1131004.67
same problem here, too
got 1110 / 1115 Passed Testcases
My Code:
double l = (p - sqrt((p * p) - (24 * a))) / 12;
double ans = (l * a * 0.5) - (l * l * p * 0.25) + pow(l, 3);
return ans;
Thanks for the amazing explanation
Glad it was helpful!