c - Reverse a substring from a string -


i looking better algorithm solve problem.

problem: check given string if given substring present , reverse substrings in given string.

example: string:

can can can canner can can can

substring:

can

output:

nac nac nac nacner nac nac nac

what better algorithm solve problem?

you can first search substrings using knuth-morris-pratt , can replace them reverse order.

as i've passed data structure course in university, algorithm has performance, in time complexity point of view.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -