Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Anagram Difference Detection

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

Your question is Anagram Difference Detection. 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

Guidewire ClaimCenter may need to compare two case-sensitive text values where character order is irrelevant. Given two strings, calculate the minimum total number of character deletions required to make them anagrams of each other.

A deletion can remove any one character from either string. Return the total number of deletions needed after retaining the largest possible set of matching character frequencies.

Formal Specification

Implement anagram_difference(s1, s2), which accepts two strings and returns an integer. Characters are lowercase English letters from a through z; repeated characters count separately. The strings do not need to have the same length.

Constraints

  • 0 <= len(s1), len(s2) <= 10^5
  • Each character is a lowercase English letter
  • Characters are case-sensitive
  • Return the minimum total deletions from both strings

Function Signature

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