http://www.geeksforgeeks.org/searching-for-patterns-set-5-finite-automata/kodeknight pattern matching See alsoFor a Given node of a binary tree, print the K distance nodes.Find the distance between 2 nodes in Binary TreeFind the distance between 2 nodes in Binary TreeProgram to count leaf nodes in a binary treeFriend Circle - Hackerrank