Distinct Substrings (SPOJ) Trying to solve using Trie but getting SIGSEGV

Problem Link

I was trying to solve Distinct Substrings on spoj.I know it can be solved using Suffix Array But I think it can also be solved using Trie…here is my solution which is getting SIGSEGV (don’t know why).Please tell me where i am wrong.

My C++ code

what i did: for string ABABABB taking substring of it : ABABABB BABABB ABABB BABB ABB BB B putting it into Trie one by one.Whenever new character is inserted count is increased by one. Each node has 26 child.

Can anybody tell me why i am getting SIGSEGV. Thanks in Advance… :slight_smile: