This problem was asked by Facebook as per Daily Coding Problem.
Given a string and a set of delimiters, reverse the words in the string while maintaining the relative order of the delimiters. For example, given "hello/world:here", return "here/world:hello"
Follow-up: Does your solution work for the following cases: "hello/world:here/", "hello//world:here"
Note :- I don't agree with above Follow-up point as relative order is changing, I think so.
So either 1st example is correct or the Follow-up example. For below solution I am
considering first example as the correct one.
Given a string and a set of delimiters, reverse the words in the string while maintaining the relative order of the delimiters. For example, given "hello/world:here", return "here/world:hello"
Follow-up: Does your solution work for the following cases: "hello/world:here/", "hello//world:here"
Note :- I don't agree with above Follow-up point as relative order is changing, I think so.
So either 1st example is correct or the Follow-up example. For below solution I am
considering first example as the correct one.