How To Implement Longest Matching Prefix, geeksforgeeks.