Skip to content

Instantly share code, notes, and snippets.

@bunnykek
Created October 18, 2023 13:04
Show Gist options
  • Save bunnykek/1c403139edc6578ee1f873e1a6936f1e to your computer and use it in GitHub Desktop.
Save bunnykek/1c403139edc6578ee1f873e1a6936f1e to your computer and use it in GitHub Desktop.
Acone Twilio product that we offer customers is the ability to send text messages programmatically. With a simple line of code, you send a user either an SMS (text- based) or MMS (media-based) message. While sending and receiving images is a common use case for customers, there are bandwidth limits for the size of each text message. For each channel that the user uses to send a message, there is a fixed bandwidth that cannot be exceeded.
We are given two lists.
1. List A represents the required bandwidth for each message, and
2. List B represents the available bandwidth for each channel.
We are given the available bandwidths of each channel in List B. For each of these channels, compute the total number of messages in List A that meet the below criteria:
• Each message in List A should require a bandwidth that is less than or equal to the available bandwidth of a channel in List B.
int main() {
vector<int> lista = {1, 2, 3};
vector<int> listb = {2, 4};
sort(lista.begin(), lista.end());
vector<int> ans;
for(int num: listb){
auto pt = lower_bound(lista.begin(), lista.end(), num+1)-lista.begin();
ans.push_back(pt);
}
for(auto num: ans) cout<<num<<" ";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment