Close

Implementing power function

Given the base and exponent, how do we implement the pow(base,exp) function efficiently? For example  pow(2.0,5) = 32 pow(0.4,2) = 0.16 pow(2.0,-2) = 0.25 For simplicity, let us assume that the base can be a decimal number and exponent can be any integer. A straight forward implementation that comes to mind is simply multiplying the…

Finding equal sum index

Given an array of numbers, find an index such that the sum of numbers to the left is equal to the sum of elements to it’s right. If there are no elements to the left or right, the sum is considered to be zero.This problem is from Hackerrank. Click here to solve this problem on…