Challenge: 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 and sparsed array of strings.


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


Index (location) of the target string

Sample input

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

target = "educative"

Sample output


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