@shawngao Thanks for the post. Your idea is great. One thing want to mentioned, when I come back to see your solution, it is concise right now which harder to come out the idea than before though I can understand but idea is important. I may wrong but I think it will be better to keep your previous solution you've posted before and add the concise solution under that.
Unique Substrings in Wraparound String