I have given my phone screen round for Google today so the question goes like this
there is some story written which is of no use
Now the main part we will be given a list of log messages from different sources and we have to truncate those log messages based two conditions
Now we have to find a maximum value of X such that after truncation the total truncated messages is max_size or fewer. And print the trucated list
Solution:
Ex:
Struct LogMessage{
string source;
string content
};
vector<LogMessage>logMessages = {
{source_a, m},
{source_a, m},
{source_b, m}
};
max_size = 2;
After truncation --> vector<LogMesaage> trucatedList = { {source_a, m}, {source_b, m} }