Amazon Online Assessment (OA) - Count Triplet Sum Permutations
The following function accepts 3 parameters:
list
, a list of integers,size
, the size oflist
,target
, the target product value for a triplet The function counts the number of triplets fromlist
whose product equals to thetarget
value.
Examples
Example 1:
Input:
size = 6
list = [1, 6, 9, 4, 2, 3]
target = 24
Output: 2
Explanation:
There are 2 triplets [1, 6, 4]
and [4, 2, 3]
that produce the product value of 24
.
The current implementation of the function compiles successfully but does not return the correct result consistently. Please fix the code so that it passes all test cases.
Try it yourself
Solution
Title
Script
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
Ipsum
has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
Contrary to popular belief, Lorem
Ipsum
is not simply random text.
>>> a = [1, 2, 3]
>>> a[-1]
3