this approach to find floor of square root of given number uses binary search algorithm, potentially reducing time complexity from root(n) to O(logn)
#java#binarysearch#optimalsolution
optimal solution:
hint: sum(n natural no.) - sum(array ele) = x-y
sum(n2 natural no.) - sum(array ele when each ele is raised by 2) = x+y
where x = duplicate ele and y = missing ele
#optimalsolution#java#DSA
Who can find the optimal solution on the first try without seeing the logic? 🤔.comment "Y" below. I said optimal, not an inorder method. #OptimalSolution #ProblemSolvingX