Can a Dictionary Word Be Formed from Note Letters?
Updated
Problem statement
Given a string note and an array words, return true if at least one dictionary word in words can be formed from the letters of note. Otherwise return false.
The letters may come from anywhere in note, in any order, and extra letters may be left over. Each letter of note can be used at most once per word. Check each word on its own: trying one word does not use up letters for another.
All characters are lowercase English letters. Every dictionary word is nonempty, but note and words may be empty. An empty words, or an empty note with nonempty words, gives false. Do not modify the inputs. Return only the Boolean, not a matching word or its index.
Function
canFormAnyWord(note: String, words: String[]) → booleanExamples
Example 1
note = "tacx"words = ["cat","act"]return = truetacx has a t, an a and a c, so cat can be formed. So can act.
Example 2
note = "ab"words = ["aa","ba"]return = trueaa needs two a letters, but ab has only one. ba can be formed from the a and the b.
Example 3
note = "xyz"words = ["cat"]return = falsexyz has none of the letters c, a or t, so cat cannot be formed.
Constraints
0 <= note.length <= 2000.0 <= words.length <= 200.- Each word contains from
1through500lowercase English letters.
More Atlassian Phone Screen questions
- Merge Overlapping IntervalsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Tennis Court SchedulingPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Implement a Rate LimiterPHONE SCREEN · Seen Oct 2026
- Longest Consistent Activity StreakPHONE SCREEN · Seen Sep 2026
- Music Player Operation SequencePHONE SCREEN · Seen Sep 2026
- Underline Shortest Unique SubstringsPHONE SCREEN · Seen Aug 2026
- Word Path Moving Only Right or DownPHONE SCREEN · Seen Feb 2026
- Ordered Badge Entry and Exit ViolationsPHONE SCREEN · Seen Aug 2025
- Two Sum with an Ordered Index PairPHONE SCREEN · Seen Aug 2025
- Can You Finish the Teleporter Board?PHONE SCREEN · Seen Jul 2025
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