We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. C++
  3. Debugging
  4. Messages Order
  5. Discussions

Messages Order

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 76 Discussions, By:

recency

Please Login in order to post a comment

  • aadinew7
    2 weeks ago+ 0 comments

    Here are the solution of Messages Order in C++ Hacker Rank Solution

    0|
    Permalink
  • brokenprogramme1
    2 weeks ago+ 0 comments

    Here are the solution of Messages Order in C++ HackerRank Solution https://www.brokenprogrammers.com/messages-order-in-cpp-hackerrank-solution/

    0|
    Permalink
  • petes40
    3 weeks ago+ 0 comments
    class Message {
        int currId;
        string text;
    public: 
        Message() : currId{0}, text{} {}
        Message(int id, const string &msgText) : currId{id}, text{msgText} {}
        
        const string& get_text() const {
            return text;
        }
        
        friend bool operator<(const Message &lhs, const Message &rhs)
        {
            return lhs.currId < rhs.currId;
        }
    };
    
    class MessageFactory {
        int msgId = 0;
    public:
        MessageFactory() {}
        Message create_message(const string& text) {
            return Message{msgId++, text};
        }
    };
    
    0|
    Permalink
  • gcysne
    3 weeks ago+ 0 comments
    class Message {
        std::string value;
        long long position;
    public: 
        Message() {
            static long long _global_order = 0;
            this->position = _global_order;
            _global_order++;
        }
        const string& get_text() {
            return this->value;
        }
        void set_text(const string& text) {
            this->value = std::string(text);    
        }
        bool operator < (const Message& other){
            return this->position < other.position;
        }
    };
    
    class MessageFactory {
    public:
        MessageFactory() {}
        Message create_message(const string& text) {
            Message msg;
            msg.set_text(text);
            return msg;
        }
    };
    
    0|
    Permalink
  • poonamdeorasurp1
    3 weeks ago+ 0 comments

    Here is problem solution - https://thecscience.com/hackerrank-messages-order-in-cpp-problem-solution.html

    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy