Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Reverse List and Anagram
00:00
5 left

Reverse List and Anagram

EasyPython

Problem

Tata Consultancy Services (North America) receives ordered keyword lists from internal tooling. Given a list of words and a target word, reverse the list and identify every word in the reversed order that is an anagram of the target.

Two words are anagrams when they contain the same letters with the same frequencies. Matching must be case-insensitive, and every input word contains only alphabetic characters.

Formal Specification

Implement reverse_and_find_anagrams(words, target).

  • Input: words, a list of strings, and target, a string.
  • Output: A dictionary with two keys:
    • reversed: the input words in reverse order.
    • matches: the words from reversed that are anagrams of target, preserving their reversed order.

Do not modify the original words list.

Constraints

  • 1 <= len(words) <= 10^4
  • 1 <= len(target) <= 10^3
  • The total number of characters across all words is at most 10^6
  • Every word and target contains only alphabetic characters
  • The original words list must not be modified

Function Signature

def reverse_and_find_anagrams(words, target):
Interviewer

Your question is Reverse List and Anagram. Start with the requirements in the Question tab.

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.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.