Find the First Matching Ordered Entry
Updated
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.
More Figma interview questions
- Layer History with Batch Undo and RedoOA · PHONE SCREEN · Seen Sep 2026
- Document and Layer OperationsOA · Seen Sep 2020
- Recursive Display SortPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Route Graph Reachability with a Broken LinkPHONE SCREEN · Seen Oct 2026
- Rich Text Parser Part 3 (Depth Tokens)PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Rich Text Parser Part 2 (Parse Nested Groups)PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Rich Text Parser Part 1 (Validate Tokens)PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Table Selection and Color UpdatesPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
- Sort Documents Left to RightONSITE INTERVIEW · Seen Aug 2026
- Symmetric Binary TreeONSITE INTERVIEW · Seen Feb 2026
Similar questions at other companies
- Product Record SearchWells Fargo · OAWells Fargo interview questions
- Closest Version DateAmazon · ONSITE INTERVIEW
- Find Unmet Users With Shared InterestsPalantir · ONSITE INTERVIEWPalantir interview questions
- Search a Sorted Array of WordsExpedia · ONSITE INTERVIEWExpedia interview questions
- Lexicographic Search SuggestionsGoogle · ONSITE INTERVIEWGoogle interview questions
- Find the Words for Each PrefixDocuSign · PHONE SCREENDocuSign interview questions
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- Find Words That Can Be Formed by CharactersTabaPay · OA
- Word Frequency Counts in Alphabetical OrderAbridge · OAAbridge interview questions
- First Missing Number in a Consecutive ArrayArista Networks · OA · PHONE SCREENArista Networks interview questions