for the test case 69, the input is [3,3,8,8], the expected result is "true".
for me, if i strictly compare the possible outcome with 24.0, i will get "false",
but if i round my possible outcome to hundred thousandths, then i can get the "true". So, i just wondering why we need to round our outcome.
Here is my assumption, when we do the divide operation, the result we get may be is a round value, like 1/3. so if we strictly compare we possible outcome with 24, we may miss some matching "24"s.
If it is true, what if the real result is not "24" but can be rounded to "24", will this cause the wrong output?
I failed on this test case as well. Try the following code and you may get a clue.
double num1 = 3.0 - 8.0 / 3.0; double num2 = 8 / num1; System.out.println(num2 + " " + num1);
We can define an epsilon value like 0.0001. Since all numbers are integer within certain ranges, it is possible to come up with an epsilon value that can distinguish a real 24.0 or a number near 24.