hasSubsequence implementation