YOUR TRACK · 2 QUESTIONS

Python & Coding

Practice data structures, problem solving, and clean Python.

Showing 2 of 2 questions

Interview-ready answer

A list is an ordered, mutable sequence that allows duplicates. A tuple is an ordered sequence that cannot be reassigned item by item. A set stores unique hashable values and is useful for membership and set operations. A dictionary maps unique hashable keys to values. Choose based on whether you need order, mutation, uniqueness, or key-based lookup.

Interview-ready answer

Scan the string once while storing characters already seen in a set. If the current character is already present, the string contains a duplicate; otherwise add it and continue. This takes O(n) expected time and O(k) extra space, where n is the string length and k is the number of distinct characters. Clarify whether comparison is case-sensitive and whether spaces count.