Find the First Matching Ordered Entry
Problem statement
Given a lexicographically nondecreasing array of lowercase ASCII strings entries and a lowercase ASCII string target, return the index of the first entry equal to target.
If target does not appear, return -1. Duplicate entries are allowed.
Function
findOrderedEntry(entries: String[], target: String) → intExamples
Example 1
entries = ["ant","bee","cat","dog"]target = "cat"return = 2cat appears at index 2.
Example 2
entries = ["a","b","b","b","c"]target = "b"return = 1The first of the three matching entries is at index 1.
Example 3
entries = []target = "z"return = -1An empty collection contains no matching entry.
Constraints
0 <= entries.length <= 200000.- Each entry and
targetcontains between1and100lowercase ASCII letters. entriesis sorted in lexicographically nondecreasing order.