You are given a structure struct LogMessage { string source; string message; }; Source is the filename and message is the log messages. There is a list of source(files) and log messages. You are given a limit of max log messages which you have to return on a fair basis. Example: { f1: "msg1", "msg2", "msg3","msg4" f2: "msgA", "msgB", "msgC", "msgD" f3: "msgX" } Suppose if max limit is given as 5, then from file 1, return 2 messages, file2 return 2 messages and file 3, return 1 message.
Anónimo
Please post your thoughts and answers and if possible dry run of code. I used hashing to store messages and roundrobin to fetch messages.