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.
- Prepare
- Algorithms
- Strings
- Two Characters
- Discussions
Two Characters
Two Characters
Sort by
recency
|
1144 Discussions
|
Please Login in order to post a comment
Just realized that i invested like 1 hour doing a algorythm that recursively check every possibility with any numbers of char set above 2. Almost passed every test, but the was a timeout issue. Folks out there pay attention to the last sentence... TWO CHARACTERS, not 3, not 4, not N, just maximum of two:
Given a string, remove characters until the string is made up of any two alternating characters. When you choose a character to remove, all instances of that character must be removed. Determine the longest string possible that contains just two alternating letters.
Hint, there is no need to be efficient here, so just try what seems eassiest:
Fastest Solution in C++
include
include
using namespace std;
int main(){ ios::sync_with_stdio(false); cin.tie(nullptr);
}
return 0 and be surprised