Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Scrabble Letter Word Check

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Scrabble Letter Word Check. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

For a word-based feature in the Nordstrom app, determine whether a requested product keyword can be formed from a customer's seven-letter rack. Each rack letter can be used at most once, and letter order does not matter.

Implement can_spell_word(letters, word) and return True if the word can be formed using only the available letters. Return False otherwise.

Formal Specification

  • Input: letters, a lowercase string containing exactly seven English letters, and word, a lowercase string containing one to seven English letters.
  • Output: A Boolean indicating whether every character in word appears in letters with sufficient frequency.
  • Repeated letters must be matched separately. For example, one o cannot satisfy two required o characters.
  • Do not modify either input string.

Constraints

  • len(letters) == 7
  • 1 <= len(word) <= 7
  • Both strings contain only lowercase English letters
  • Each character may be used at most once

Function Signature

def can_spell_word(letters, word):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output