Input Format
The input is read by the provided locked code template. It contains several lines of text messages in the order that they will be sent over the network.
  • There will be at most  lines in the input.
  • Each line will contain at most  characters
Output Format
The output should be produced by the provided locked code template and it is produced as described in details in the statement. The expected order of printed messages is the same as the one in the input.

hackerrank messages order problem solution in c++ programming

Messages order problem solution in c++ programming | HackerRank

class Message {
    Message() {}
    Message(const string& text, int id) : text_(text), id_(id) {}
    const string& get_text() {
        return text_;
    bool operator<(const Message& rhs) const {
        return this->id_ < rhs.id_;
    string text_;
    int id_;

class MessageFactory {
    MessageFactory() {}
    Message create_message(const string& text) {
        return Message(text, current_id++);
    int current_id = 0;