Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Palindrome and Anagram Coding
00:00
5 left

Palindrome and Anagram Coding

EasyPython

Problem

Cvent event configuration tools may validate short text fields before processing them. Given three strings, determine whether the first is a palindrome and whether the second and third are anagrams.

A palindrome reads identically from left to right and right to left. An anagram contains exactly the same characters with the same frequencies, possibly in a different order. Treat characters as case-sensitive and include spaces and punctuation in both checks.

Formal Specification

Implement check_strings(s, a, b):

  1. Return true for the first result if s is a palindrome, otherwise return false.
  2. Return true for the second result if a and b are anagrams, otherwise return false.
  3. Return the results as a two-element list: [is_palindrome, are_anagrams].

Constraints

  • 0 <= len(s), len(a), len(b) <= 10^5
  • Strings contain printable ASCII characters
  • Comparisons are case-sensitive
  • Spaces and punctuation are treated as regular characters

Function Signature

def check_strings(s, a, b):
Interviewer

Your question is Palindrome and Anagram Coding. 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
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.