Find the k substring index range
Problem to find the string k starting and ending index of given string.
Example-1:
Input : s = "ilovemycrazycoding" k = "crazy" Output : 7 11
Example-2:
Input : s = "flightflowflower" k = "fl" Output : 0 1
Solution
s = "ilovemycrazycoding" k = "crazy" if(k not in s): print(-1) else: a = s.index(k) b = a + (len(k)) print(a,b-1)
Output
7 11