12 AnswersNew Answer
If you have already Solved it then need to further discussion here. If you are getting any problem you can ask.
With every i you only have to compare with the letters right from it (j=i+1).
I don't think you need to put "put(a)" at the end
I used strchr and strrchr (in a for loop) from the string.h header file and compare what get returned...if they are different... then "Deja Vu".
Hey, i think a better way is to create a array of char or string and sort it. If a string contains a duplicate than it will be set one by one gradually. Like "bacda" after sorting it becomes "aabcd". So it will be quite easy to find duplicate. And furthermore if you use Java than you have to try Hashset or LinkedHashset. Main use of this type of collections is it does not allow duplicates value.If you put a duplicate value in Hashset it will remove it. If you put "bacda" Hashset will return something like "bacd" if "bacda" ! ="bacd" //repeated else //norepeated
Remove puts(a) 21st line then you get exact result
oo ok thnx
i changed the double letter only problem,and now it is runs better,but your example will only search for repeats between 2 adjacent letters only.
yeah, that totally isn't a good solution even though it worked. i do it this way, first create an int array of 26 size where all of it is set to 0 where each index represents an alphabet. ex arr is for a, arr for b... the array value will represent the amount of alphabet so when you loop through the string, and found an 'a' then arr will add by 1. after adding 1 on the index check if the value is 2, which means there are 2 'a' s already, then print deja vu if you reach the end of the string then print unique turning the character 'a' into 0 involves the use of ascii numbers, i suggest you study it. so the ascii of a = 97, b = 98. you just need to decrease the ascii value by 97 and you will return the index to store on your array. this is how i solve it and in my opinion the simplest way.
Yeah this is a nice method.