@saurabh koar : no it will give that sub array .. but "kishan das" solution
is good...
btw my code explanation is
A: 2 4 3 5 6
PRODUCT: 2 8 24 120 720
SUM 2 6 9 14 20
suppose i want sum 8 and product 15
make hash table for product array (in hashtable store index of product in
array A)
suppose at index K..
devide A[i]/15 if we get A[i]/ 15 in hash table it means (i+1) to k
contains product needed now check for sum ..check ( sum[k]-sum[i]==GIVEN
SUM) we get answer A(i+1 to k)
example
at k =3 120/15=8 will be present in hash table..get index of 8 in array
A..here 1 now compute SUM[3]-SUM[1]..which is 8 here as required so answer
is A(i+1 to k ) means A(2 to 3) ={3,5}
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.