Any pointer at algorithm teaching for the substring and shifted index m ethod? I search online but ti doesn’t seem to be a usual terminology.
Ice Hunter and Northwest both use the substring search algorithm, but I found the code comments and the level explanations (help/hints) quite poor. The hint talks about double loop, it does not explain the algorithm.
My son and I can code at basic level, but I am not familiar with the algorithm these levels try to teach.
I try to understand the algorithm, not the code.
We get the code working, but not the “why” behind:
- why do we “iterate through the start indexes only.”, what is the purpose of rightedge
- why using “i in range(rightEdge + 1):” to parse the word/text, as opposed to start from the beginning?
- Once in the nested loop, why using shiftedIndex, for what purpose, as opposed to start comparing from the substring’s beginning?