educative.io

Educative

I don't understand why example 2 returns false

Why is this false:

Input: String="odicf"
Pattern="dc"
Output: false
Explanation: No permutation of the pattern is present in the given string as a substring.

“dc” is in the string, I don’t understand why it’s false.


Type your question above this line.

Course: https://www.educative.io/collection/5668639101419520/5671464854355968
Lesson: https://www.educative.io/collection/page/5668639101419520/5671464854355968/5401934796161024

Hi @john2 ,
Yes d and c are in the string but not as a consecutive sequence. By definition, a substring is a contiguous sequence of characters. d and c are separated by an i between them hence the output false.