how to find duplicate string in given passage using c or java?
As in, you are given a string and you want to see if it occurs more than once? Well, most string searches return the start point of the match. So you search a second time after the first match. As in, the command lets you say where to start searching and you use the start point you found plus the length of the sub string as the location to start searching again.
Can you give me a program?
Here are some basics of it: http://stackoverflow.com/questions/7764027/how-to-find-duplicate-string-in-an-array-of-strings http://stackoverflow.com/questions/15356974/how-to-find-duplicate-string-from-an-array-of-string
thank you
Another thing to consider that works in a lot of languages is a string split using the substring as a delimiter. A lot of languages implement a split() that returns an array of strings created by breaking the haystack at each occurrence of needle. You can then look at the length of the array to identify the number of occurrences, or the lengths of the elements to identify the locations of said instances.
Join our real-time social learning platform and learn together with your friends!