unable to find the mistake in my code
input-{ “zebra”, “dog”, “duck”, “dove”}
output coming(my)- ze,dog,duc,dov,
$ Unique Prefix Array-wrong ans coming
Your code and logic is almost right but there are some small mistakes in it:-
(i) During the insertion, you are incrementing the count of temp at line 31, which should be after the line 32 because initially you are at root which is NULL so you need to first move to the right character.
(ii) While printing, you have to update the temp variable every time where the count==1 or not, so move the line no 68 before the if-else statements.
Rest all the code is absolutely perfect.
Hope it helps, feel free to ask any furthur doubt in it.