Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Find FLAMES Between Two Names

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

Your question is Find FLAMES Between Two Names. 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

The College Board SAT Suite may need a small string-processing utility for profile-name experiments. Given two names, compute their traditional FLAMES result after removing matching letters.

Normalize both names by converting letters to lowercase and ignoring spaces, punctuation, and other nonalphabetic characters. Cancel matching letters with multiplicity: each occurrence in one name can cancel at most one occurrence of the same letter in the other name. Let k be the total number of uncanceled letters across both names.

Use k to eliminate entries from the circular list ['F', 'L', 'A', 'M', 'E', 'S']. Starting at index 0, remove the kth remaining entry, counting the current entry as 1. Continue counting from the position immediately after each removed entry until one entry remains.

Return the remaining FLAMES letter. If k is zero, return "NONE".

Formal Specification

  • Input: Two strings, name1 and name2.
  • Output: A string containing one FLAMES letter, or "NONE" when no letters remain.

Constraints

  • 0 <= len(name1), len(name2) <= 10^5
  • Inputs contain printable characters
  • Matching is case-insensitive
  • Only alphabetic characters participate
  • Duplicate letters are canceled by occurrence

Function Signature

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