Given an sorted array of unique integers , the task is to find the lcm of all element except current element .
my logic is using two loops and find lcm of all elements except current element, but it is two slow i think this can be done in O(N) but i can't get any idea , i tried same approach to find the product of array except self ( just product all array and for finding answer diivide it by current element) but this will not work in case of lcm or GCD.
Ex: a=[10,12,15]
ans = [60,30,60] // for LCM
ans = [3,5,2] //for GCD
This question is asked in one of senior's interview and they ask me i tried in O(n^2) but they tell me it can be easily done in O(N)