Challenge 9: Sparse Search

Given a sorted array of strings interspersed with empty strings, find the index of a given string.

Problem Statement

Implement a function that returns the index of the target string in a sorted, sparsed array of strings.

Input

A sparsed, sorted array of strings and the target string whose location needs to be found.

Output

Index (location) of the target string.

Sample Input

array = {"", "educative", "", "", "",  "hello", "", "learning", "world", "", "", ""};

target = "educative"

Sample Output

1

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.