Open biplobmanna opened 1 year ago
It might be a little difficult to realize that there is a small issue in the algorithm for two crystal balls as shown in FEM-DSA course, so here's a short snippet show casing the original test cases passing, and the new test case failing for the original code. Also, the modified code passes the newly added test case.
https://user-images.githubusercontent.com/5135690/223803971-04393800-1dc3-44e8-afe6-d99853ec3336.mp4
algo shown in FEM - twocrystalballs misses a case where index of first
true
is perfect sqrt-factor of arr size (arr must be perfect sq size)adding test case to check for such instance
example:
in the above example,
return = -1
based on the algo shown on FEMerror due to classic case of exclusion of the index where
true
is found in the firstfor
loop (first ball smash)