Microsoft Interview Question
- 0of 0 votes
find the balance index of an array where balanced index i is defined as the one whose left sum is equal to the right sum of the index .
summation (1 to i-1) = summation (i+1 to length of an array) firdt I gave o(n2) solution , but then before i could give O(n) solution it was time up for me,
O(n) solution will be we have to loop through i = 1 to N and find if ( sum of array - sum of array (1 to i-1 ) = ( sum of array - sum of array (1 to i+1 ) the return i.
Interview Type: In-Person