Skip to content Skip to sidebar Skip to footer

Find Method With Empty String

I was playing around with a function for an assignment just to better understand it. It was meant to find the last occurrence of a sub-string within a string. The function should r

Solution 1:

The empty string can be found at any position. Initializing start with -1 makes your algorithm beginning its search at the penultimate position, not the last.

The last position is after the last character of the string, but you are starting to look at the last character of the string.

Post a Comment for "Find Method With Empty String"