Answer: Amazon, Recent Online Assessment Questions (13th August 2023) | Discount on Purc
Answer · Posted Aug 2023
Question 1 solution // C++ Program to count pairs // whose sum divisible by 'K' #include <bits/stdc++.h> using namespace std; // Program to count pairs whose sum divisible // by 'K' int countKdivPairs(int A[], int n, int K) { // Create a frequency array to count // occurrences of all remainders when // divided by K int freq[K] = { 0 }; // Count occurrences of all remainders for (int i = 0; i < n; i++) ++freq[A[i] % K]; ...
The full answer & interview discussion are available to premium members.
Log in Create a free account