Amazon Online Assessment (OA) - Count Triplet Sum Permutations

The following function accepts 3 parameters:

  • list, a list of integers,
  • size, the size of list,
  • target, the target product value for a triplet The function counts the number of triplets from list whose product equals to the target 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

Get premium for instant access to all content and solutions

Upgrade