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
Post a Comment