I was solving a problem from spoj, Link. I need to keep two same string in the prefix_trie. For first query the answer 2, but I am getting 1. Because the duplicate is not counted. My code link . One more thing I want to how can I print the size of prefix range in O(1). Please Help.