Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
LeetCode-Style String and Math
00:00
5 left

LeetCode-Style String and Math

MediumPython

Problem

How would you approach LeetCode-style palindrome and odd-number problems?

Implement palindrome_and_odds(s, nums). Determine whether s is a palindrome after ignoring non-alphanumeric characters and case, then return all odd integers from nums in their original order. Return an object with boolean is_palindrome and integer-array odd_numbers fields.

Constraints

  • 0 <= len(s) <= 1000
  • s contains Unicode characters, spaces, and punctuation
  • 0 <= len(nums) <= 1000
  • -10^9 <= nums[i] <= 10^9
  • The order of nums must be preserved in odd_numbers

Function Signature

def palindrome_and_odds(s, nums):
Interviewer

Your question is LeetCode-Style String and Math. 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.