Skip to content

Conversation

@dmonroe85
Copy link

Added a solution that takes the same approach as the original method (s2 in s1 + s1), but it compares the strings in place and requires constant additional memory.

" matching_count, i2 = 0, 0\n",
"\n",
" # Increment i1 and wrap around if necessary\n",
" i1 += 1\n",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i1 += 1 if i1 == length: i1 = 0

can be replaced by:

i1 = (i1 + 1) % length

which is a common idiom for wrap-around semantics in iteration.

@dmonroe85 dmonroe85 closed this by deleting the head repository Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants