Detect words formed by multiple dictionary parts | Amazon Interview Question