You are viewing a single comment's thread. Return to all comments →
Following the wonderful observation by @baran_jana, we can make do with only a frequency array of size 201:
int n; cin >> n; int pivot, value; cin >> pivot; int freq[200 + 1] = { 0 }; freq[100] = 1; for (int i = 1; i < n; ++i) { cin >> value; freq[100 + (value - pivot)]++; } int m; cin >> m; for (int i = 0; i < m; ++i) { cin >> value; freq[100 + (value - pivot)]--; } for (int i = -100; i <= 100; ++i) { if (freq[100 + i] != 0) cout << (pivot + i) << " "; } return 0;
Seems like cookies are disabled on this browser, please enable them to open this website
Missing Numbers
You are viewing a single comment's thread. Return to all comments →
Following the wonderful observation by @baran_jana, we can make do with only a frequency array of size 201: