Little Jhool and his breakup

After minting loads of money from innocent people by using the psychic powers (As we saw in the previous question!) - little Jhool managed to woo his girlfriend big Jhool! And now, he's in love - madly, madly in love with his girlfriend.

But the road to love is not easy as they say, little Jhool and big Jhool live in two different cities, and they often have to rely on multiple online clients to communicate. And many times, due to frustration, little Jhool starts hitting his keyboard, pressing the wrong keys - and thus, he ends up sending her a meaningless message, which frustrates his girlfriend - obviously. But big Jhool is a smart girl and she knows what to reciprocate back to her boyfriend's message based on the message she has received from him.

She figures that if and only if, she can delete several characters from the message sent by her boyfriend, resulting in the word "love", it will be considered that she managed to understand his message, and if not... well, some trouble is waiting for her boyfriend!

Example:

Input:  s = "lov3333333asdafajfgnkdfn33333e"
Output: I love you, too!

Approach

C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s = "lov3333333asdafajfgnkdfn33333e";

    int n = s.size();
    bool L = falseO = falseV = falseE = false;
    for (int i = 0i < ni++)
    {
        if (s[i] == 'l')
            L = true;
        else if (s[i] == 'o' && L == true)
            O = true;
        else if (s[i] == 'v' && O == true)
            V = true;
        else if (s[i] == 'e' && V == true)
            E = true;
    }
    if (L == true && O == true && V == true && E == true)
        cout << "I love you, too!\n";
    else
        cout << "Let us breakup!\n";
    return 0;
}


No comments:

Post a Comment