+ 5
Challenge: remove duplicate words from a given string, but there s a catch
Rules -remove all duplicate words from the string , preserving first occurrence -note that "so" and "so," are duplicates too, but comma or any grammatical sign must be preserved at all times but not the duplicate word sample text- "so we started so, we start again the gain, we! never give up up! up;" o/p:" so we started , start again the gain, ! never give up ! ;"
6 Réponses
+ 3
this question was asked in my technical interview for software engineer post in oracle cloud, and I failed that, but a lesson learned the hard way
+ 7
Interesting! Here's my take on it in C#. ✌
I hope there's a neater and elegant way to solve the problem and let's wait and see for more submissions. 😉
https://code.sololearn.com/cv3GVPqnmDT4/?ref=app
+ 5
Here's my try.. A bit long..I encountered some bugs..😅 So tell me if there are any errors.
https://code.sololearn.com/WBE1UBMblS58/?ref=app
+ 2
👌 @Jonathan, a cool UI, adds a cherry topping on the perfect solution, I tried to take on this problem with c++, my native language, but comparatively to JS or python which are awesome in parsing applications, it's so time taking to come up with bug free solution
example 30% of task was done split(" ");
+ 1
3 lines. Note the hack to replace all but the first occurence....
https://code.sololearn.com/c9IzzIc5jzV2/?ref=app