Check Ordered Letter Containment
Updated
Problem statement
Given two strings s and t, return true if all character occurrences of s can be selected from t in the same order. Otherwise, return false.
For this exercise, assume each character occurrence of s must match a different position in t. The selected target positions must be strictly increasing. You may skip other characters of t; the selected positions do not have to be consecutive.
For this exercise, the empty string is contained in every target, including an empty target. A nonempty s is not contained in an empty t.
Function
containsOrderedLetters(s: String, t: String) → booleanExamples
Example 1
s = "abc"t = "axbzyc"return = trueThe characters at indices 0, 2 and 5 of t form abc. Other characters may be skipped.
Example 2
s = "acb"t = "abc"return = falseAfter matching a and c, no b remains to their right. Having all distinct letters is insufficient.
Example 3
s = "aa"t = "a"return = falseThe two occurrences of a in s need two different positions in t.
Constraints
- For this exercise, assume
0 <= s.length, t.length <= 1000. - For this exercise, both strings contain only lowercase English letters
athroughz.
More NVIDIA Phone Screen questions
- Network Layer Execution OrderPHONE SCREEN · Seen Nov 2026
- Paged KV Cache AccessPHONE SCREEN · Seen Nov 2026
- Sliding Window Attention over a KV CachePHONE SCREEN · Seen Nov 2026
- Summarize Server Healthcheck LogsPHONE SCREEN · Seen Oct 2026
- Hash Partition OffsetsPHONE SCREEN · Seen Oct 2026
- Filter Paginated Medical RecordsPHONE SCREEN · Seen Oct 2026
- Least Frequently Used CachePHONE SCREEN · Seen Oct 2026
- Parallel String Counts with a Custom Hash TablePHONE SCREEN · Seen Oct 2026
- Simulate a Reference-Counted Smart PointerPHONE SCREEN · Seen Aug 2026
- Streaming Top-K Frequent ElementsPHONE SCREEN · Seen Aug 2026
Similar questions at other companies
- Run-Length Encoding and DecodingAirbnb · PHONE SCREENAirbnb interview questions
- Check if a String Is a PalindromeCisco · PHONE SCREENCisco interview questions
- Halfway Course in a Single TrackCrunchyroll · PHONE SCREENCrunchyroll interview questions
- Reverse a StringAmazon · PHONE SCREEN
- Reverse a String ManuallyNewgen Software · PHONE SCREEN
- Reverse a String with Two PointersSnowflake · PHONE SCREENSnowflake interview questions
- Palindrome with One DeletionWhatNot · PHONE SCREENWhatNot interview questions
- Valid Word AbbreviationMeta · PHONE SCREENMeta interview questions
- Reverse a StringPersistent Systems · PHONE SCREEN
- Minimum Changes for Palindromic BlocksCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions