Check Unordered Letter Coverage
Updated
Problem statement
Given two strings s and t, return true if every distinct letter appearing in s appears at least once in t. Otherwise, return false.
For this exercise, assume order and repetition counts are irrelevant. Multiple occurrences of the same letter in s require only one occurrence in t. Extra letters in t are allowed.
For this exercise, an empty s is covered by every target, including an empty target. A nonempty s is not covered by an empty t.
Follow-up
A set-based approach works; be ready to discuss its worst-case running time. Explain the complexity of the data structure you choose.
Function
containsUnorderedLetters(s: String, t: String) → booleanExamples
Example 1
s = "aba"t = "bax"return = trueThe distinct required letters are a and b. Both occur in t; the repeated a does not require another occurrence.
Example 2
s = "az"t = "abc"return = falseThe required letter z does not occur in t.
Example 3
s = "zz"t = "z"return = trueOnly the distinct letter z must be present. Counts and order do not affect this decision.
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
- Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
- Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
- First Letter to Appear TwiceCisco · PHONE SCREENCisco interview questions
- Halfway Course in a Single TrackCrunchyroll · PHONE SCREENCrunchyroll interview questions
- Single-Condition Product FilterCrowdstrike · PHONE SCREENCrowdstrike interview questions
- Known Words Matching Phone DigitsLinkedIn · PHONE SCREENLinkedIn interview questions
- First Non-Repeated CharacterDell Technologies · PHONE SCREENDell Technologies interview questions
- Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
- First Non-Repeating CharacterGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
- SimpleRDD Word CountDatologyAI · PHONE SCREEN