+ 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 ! ;"

20th Oct 2017, 2:51 AM
Morpheus
Morpheus - avatar
6 ответов
+ 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
20th Oct 2017, 2:56 AM
Morpheus
Morpheus - avatar
+ 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
20th Oct 2017, 6:37 AM
Zephyr Koo
Zephyr Koo - avatar
+ 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
20th Oct 2017, 5:41 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 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(" ");
20th Oct 2017, 6:06 AM
Morpheus
Morpheus - avatar
20th Oct 2017, 3:25 PM
Hiroki Masuda
Hiroki Masuda - avatar
+ 1
3 lines. Note the hack to replace all but the first occurence.... https://code.sololearn.com/c9IzzIc5jzV2/?ref=app
21st Oct 2017, 2:50 AM
VcC
VcC - avatar