Computer Science, asked by relaxingwithg, 10 hours ago

You have been given a number of product IDs to collect from an Amazon fulfillment center. Each product ID must be found and packaged. However, you have been given too many product IDs to collect today, and so you need to trim some products from your list so that you can efficiently collect the rest before the day's end​

Answers

Answered by iambidiptapaul
2

Explanation:

Given an array of items, an i-th index element denotes the item id’s, and given a number m, the task is to remove m elements such that there should be minimum distinct id’s left. Print the number of distinct id’s.

Examples:

Input : arr[] = { 2, 2, 1, 3, 3, 3}

m = 3

Output : 1

Remove 1 and both 2's.So, only 3 will be

left that's why distinct id is 1.

Input : arr[] = { 2, 4, 1, 5, 3, 5, 1, 3}

m = 2

Output : 3

Remove 2 and 4 completely. So, remaining ids

are 1, 3 and 5 i.e. 3

Answered by dmrunal
0

Answer:

Given: from the list of items, items IDs denoted an i-th  element, and given a number n, we have to remove n items for minimizing the list.

Explanation:

for doing so:

Input :

arr[] =

n = 3

Output: 1

after eliminating 1 and 2. So, the most effective 3s are

left this means that most effective 1 awesome id.

Input :

arr[] =

n = 2

Output : 3

// C++ application for above implementation

#include

the usage of namespace std;

// Function to locate distinct id's

int distinctIds(int arr[], int n, int mi)

incidence of ids

   for (int i = 0; i < n xss=removed xss=removed>second, it->first));

   // Sort the vector

   sort(v.begin(), v.end());

   int size = v.size();

 // Start removing elements from the starting

   for (int i = 0; i < size; i++) {

       // Remove if current value is less than

       // or equal to mi

       if (v[i].first

Similar questions