// IMPORT LIBRARY PACKAGES NEEDED BY YOUR PROGRAM
import java.util.List;
// SOME CLASSES WITHIN A PACKAGE MAY BE RESTRICTED
// DEFINE ANY CLASS AND METHOD NEEDED
// CLASS BEGINS, THIS CLASS IS REQUIRED
class Solution
{
// METHOD SIGNATURE BEGINS, THIS METHOD IS REQUIRED
int itemPairs(int num, List itemValues, int target)
{
// WRITE YOUR CODE HERE
}
// METHOD SIGNATURE ENDS
}
Extracted text: You are given an array of integers, where each item in the array represents the price of a given item. You are also given an integer representing the target sale value. You must gather distinct pairs of items that satisfy the sales target. Distinct pairs are pairs that differ in at least one element. Given the list of prices, write an algorithm to find the number of distinct pairs of items where the sum of each pair's values is exactly equal to the target sales. Input The input to the function/method consists of three arguments: num, an integer representing the number of items; itemValues, a list of integers representing the item price; target, an integer representing the target sales. Output Return an integer representing the number of pairs having the sum of their prices equals to the target sales. Constraints 1 s num s 5* 105 OsitemValues[i] s 109 Osi< num="" os="" target="" s="" 5*="" 109="" example="" input:="" num="">
Extracted text: Example Input: num = 9 itemValues = [5, 7, 9, 13, 11, 6, 6, 3, 3] target = 12 Output: 3 Explanation: There are 8 possible pairs of prices that have the sum of their values equal to the target 12. (itemValues[0] = 5, itemValues[1] = 7) (itemValues[1] = 7, itemValues[0] = 5) (itemValues[2] = 9, itemValues[7] = 3) (itemValues[7] = 3, itemValues[2] = 9) (itemValues[2] = 9, itemValues[8] = 3) (itemValues[8] = 3, itemValues[2] = 9) (itemValues[5] = 6, itemValues[6] = 6) (itemValues[6] = 6, itemValues[5] = 6) %3D The first two pairs are same and considered as one distinct pair. Next four pairs are same and considered as one distinct pair. Similarly, last two pairs are same and considered as one distinct pair. There are only 3 distinct pairs of prices: (5, 7), (9, 3) and (6, 6).