I have to write a fn squeeze(const string &s, char c)
for ex squeeze("haaaaah" , 'a') should give the output hah
skyyadav
0
Light Poster
Recommended Answers
Jump to PostI have to write a fn
Yes you do, so what problem are you having in writing the function?
Jump to PostOne possible solution is processing the string in reverse.
So starting from the end of the string, if string element i == c and element i - 1 == c, then erase element i.std::string squeeze(const std::string& s, char c) { std::string str = s; size_t len …
All 8 Replies
nullptr
167
Occasional Poster
skyyadav
0
Light Poster
skyyadav
0
Light Poster
nullptr
167
Occasional Poster
mike_2000_17
2,669
21st Century Viking
Team Colleague
Featured Poster
skyyadav
0
Light Poster
yingdan
0
Newbie Poster
mike_2000_17
2,669
21st Century Viking
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.