Company: visa associate swe Off campus_24march
Difficulty: medium
You are given an array arr of length n and an integer d . Your task is to count the number of unique triplets ( i , j , k ) such that: 0 ≤ i < j < k < n The sum arr[i] + arr[j] + arr[k] is divisible by d Return the total count of such triplets. Example Suppose arr = [3, 3, 4, 7, 8] and d = 5 . Output: 3 Divisible triplets (using 0-based indexing): (0, 1, 2): 3 + 3 + 4 = 10 (divisible by 5) (0, 2, 4): 3 + 4 + 8 = 15 (divisible by 5) (1, 2, 4): 3 + 4 + 8 = 15 (divisible by 5) Constraints 3 ≤ n ≤ 10 3 1 ≤ arr[i] ≤ 10 9 2 ≤ d ≤ 10 6 Test Case Input Format The first line contains an integer, n , the size of arr[] . The following n lines contain an integer, arr[i] . The last line contains the integer d . public static int getTripletCount(List<Integer> arr, int d) { // Write your code here }