Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Python String and List Tasks

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

Your question is Python String and List Tasks. 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 Hp Iq QA automation pipeline receives a list of result identifiers and a diagnostic string. Implement a function that removes duplicate identifiers while preserving their first-seen order, then counts the vowels in the diagnostic string.

Return both results in a dictionary with keys unique_items and vowel_count.

Formal Specification

Implement process_results(items, text).

  • items is a list containing integers or strings. Values are compared using normal Python equality.
  • text is a string containing ASCII letters, spaces, digits, and punctuation.
  • Duplicate values in items must appear only once, at their first index.
  • Count a, e, i, o, and u regardless of letter case. The letter y is not a vowel, and accented characters are outside the input domain.
  • Return a dictionary: {"unique_items": list, "vowel_count": int}.

Constraints

  • 0 <= len(items) <= 100,000
  • 0 <= len(text) <= 100,000
  • Each item is an integer or string and is hashable
  • Only ASCII vowels a, e, i, o, and u are counted
  • The letter y is not considered a vowel

Function Signature

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