Similar Items: Quantum algorithms for path and cycle containment problems