- This question is not that hard.
- How to check if
targetis a subsequence of
Double pointers, one for
sand one for
target. If curr char is a match, move both pointers right by 1. If not, only move pointer of s.
dictby length and lexicographical order. So the first word to be found in s is our ans.
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: s = "abpcplea", dictionary = ["ale","apple","monkey","plea"]