First Dictionary Word from Note Letters
Updated
Problem statement
Given a string note and an ordered array words, return the first word that can be formed by rearranging letters from note. The first word means the one with the smallest index in the input array.
For this exercise, assume all characters are lowercase English letters, every word is nonempty, and each character occurrence in note may be used at most once to form a candidate word. Candidates are checked independently, so testing one word does not consume letters for later words.
For this exercise, assume an empty string is returned if no word can be formed. The note and the dictionary may be empty.
Function
firstWord(note: String, words: String[]) → StringExamples
Example 1
note = "balloons"words = ["son","ball","friends"]return = "son"The answer is son because it is the first constructible dictionary word; later ball is also constructible.
Example 2
note = "aab"words = ["baa","aaa","ab"]return = "baa"Reordering is allowed and each character occurrence is used at most once; baa is first.
Constraints
- For this exercise, assume
0 <= note.length <= 10^4. 0 <= words.length <= 1000.- Each word length is from
1through1000. - All characters are from
athroughz.
More Indeed Phone Screen questions
- Insert into an Unrolled Linked ListPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Course Completion OrderPHONE SCREEN · Seen May 2025
- Recipes You Can PreparePHONE SCREEN · Seen May 2025
- Rotting Orange PropagationPHONE SCREEN · Seen May 2025
- Courses Shared by Every Student PairPHONE SCREEN · Seen Aug 2022
- First and Last Access Time per UserPHONE SCREEN · Seen Jul 2022
- Most Accessed Resource in Five MinutesPHONE SCREEN · Seen Jul 2022
- Resource Transition GraphPHONE SCREEN · Seen Jul 2022
- Count Disappearing Connected TilesPHONE SCREEN · Seen Jul 2022
- Word Path Moving Only Right or DownPHONE SCREEN · Seen Jul 2022
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
- Summarize Server Healthcheck LogsNVIDIA · PHONE SCREENNVIDIA 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