Persistent Systems Interview Question

Multiple of all elements in an array except one at particular index. For example Array A = 1,2,3,4 We know to store in other arrayy B at index 2 the product of all elements except at index 2. B= [, , 8, ] Same for all index of B to fill

Interview Answer

Anonymous

Oct 5, 2024

First i started brute force using for loops. Then he gave me hint which triggered my brain i just said we will first multiple all elements of array and just divde it by respective index number. Like if we multiply elements of A we will get 1*2*3*4=24 B[0]=24/A[0]=24/1=24 B[1]= 24/A[1]= 24/2=12 which is equalnt to multiple of all elements of array A except 2 which is at index 2nd. Note :- i didnt have experience of DSA thatswhy for me it might be difficult. If u r good at coding thn its cake of walk u can easily grab 12lpa . For 5lpa loops questions For 8lpa,12lpa trees and graphs.