## Question 1 What's the correct output for the following inputs? `a` = "abab" `b` = "ab" ### Options 1. [0] Incorrect We aren't looking only for the first index of the occurrence, but rather looking for all the starting indexes of string `b` in string `a`. ---------------------------- 2. [0, 2] Incorrect Anagrams are composed of same letters but can be in any order. Hence, We aren't considering the order in which these characters appear originally. ---------------------------- 3. [0, 1, 2] Correct There are two anagrams of string `b` in string `a`. 1. "ab" starts from index 0. 2. "ba" starts from index 1. 3. "ab" starts from index 2. ---------------------------- 4. [1, 2] Incorrect ---------------------------- --------------------------------------------- ## Question 2 What's the correct output for the following inputs? `a` = "abc" `b` = "cbaebabacd" ### Options 1. [ ] Correct The length of string `a` can't be less than the length of string `b`, so it's an invalid case. Therefore, we return an empty array. ---------------------------- 2. [0] Incorrect ---------------------------- 3. [0, 6] Incorrect ---------------------------- 4. [3] Incorrect ---------------------------- --------------------------------------------- ## Question 3 What are all the anagrams of string `b` in string `a`, if the following inputs are given? `a` = "ogddoodg" `b` = "dog" ### Options 1. "doodg" (starts from index 3) Incorrect The length of the anagram we are looking at is 3, so the output can't be of length 5. ---------------------------- 2. "ogd" (starts from index 0) "odg" (starts from index 5) Correct These are the only two anagrams of string `b` in string `a`. ---------------------------- 3. "ogd" (starts from index 0) "dgo" (starts from index 2) "odg" (starts from index 5) "gdo" (starts from index 7) Incorrect We need anagrams only in the forward direction of string `a` and not in the reverse direction. These two are invalid: 1. "dgo" (starts from index 2) 2. "gdo" (starts from index 7) ---------------------------- 4. "ogd" (starts from index 5) "odg" (starts from index 0) Incorrect ---------------------------- --------------------------------------------- ## Question 4 What's the correct output for the following inputs? `a` = "unfnnufunuf" `b` = "fun" ### Options 1. [0, 2, 6, 10] Incorrect ---------------------------- 2. [0, 4, 6, 8] Correct There are four anagrams of string `b` in string `a`. 1. "unf" starts from index 0. (Remember the characters in an anagram can be in any order, they just need to be consecutive) 2. "nuf" starts from index 4. 3. "fun" starts from index 6. 4. "nuf" starts from index 8. ---------------------------- 3. [3, 7, 11] Incorrect ---------------------------- 4. [0, 3, 5] Incorrect ---------------------------- --------------------------------------------- ## Question 5 What are all the anagrams of string `b` in string `a` if the following inputs are given? `a` = "teaateat" `b` = "eat" ### Options 1. "aet" (starts from index 2) "eta" (starts from index 5) "tae" (starts from index 7) Incorrect We need anagrams only in the forward direction of string `a` and not in the reverse direction. All the given anagrams are invalid. ---------------------------- 2. "tea" (starts from index 1) "ate" (starts from index 4) "tea" (starts from index 5) "eat" (starts from index 6) Incorrect ---------------------------- 3. "tea" (starts from index 0) "ate" (starts from index 3) "tea" (starts from index 4) "eat" (starts from index 5) Correct These are the only four anagrams of string `b` in string `a`. ---------------------------- 4. "tea" (starts from index 1) "tae" (starts from index 7) Incorrect ---------------------------- ---------------------------------------------