Skip to content

Latest commit

 

History

History
13 lines (10 loc) · 704 Bytes

File metadata and controls

13 lines (10 loc) · 704 Bytes

Problem 18: Subsequence Validation Span (Longest Word in Dictionary through Deleting)

Problem Statement

Given a string s and a string array dictionary, return the longest string in the dictionary that can be formed by deleting some of the given string characters. If there is more than one possible result, return the longest word with the smallest lexicographical order. If there is no possible result, return the empty string.

Input Format

  • A string s.
  • An array of strings dictionary.

Example

Input: s = "abpcplea", dictionary = ["ale", "apple", "monkey", "plea"]
Output: "apple"

Both "apple" and "monkey" are in dictionary. "apple" can be formed, "monkey" cannot.