Interview Question
Country: India
Interview Type: Written Test
As x is acting as an index in the array and y is just there to reach the base case in recursion so given x you have to just multiply the numbers in the range from x to y. Because y will also be included as base case is to return 1 when x is greater than y. So if an array is
arr[]={3 5 6 7 8 9} and x is 2 and y is 4
So ans=arr[2]*arr[3]*arr[4]=6*7*8
Assuming the numbers are positive, doesn't it only depend on oddness/evenness of A[x]?
- Anonymous June 17, 2014If numbers can contain zero, then you need to worry about whether we can get a 0.
If numbers can be negative, then question is not well formed.