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 = false, O = false, V = false, E = false;for (int i = 0; i < n; i++){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";elsecout << "Let us breakup!\n";return 0;}
No comments:
Post a Comment