Check anagrams under real-world constraints
Company: Uber
Role: Data Scientist
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Technical Screen
Quick Answer: This question evaluates expertise in string algorithms, multiset equality, algorithmic time/space complexity analysis, memory- and streaming-aware algorithm design, Unicode normalization and case folding, and approximate string matching for k‑off anagrams.
Constraints
- Inputs are strings
- k counts single-character insertions/deletions
Examples
Input: ('abc', 'cab', 0, False)
Expected Output: True
Explanation: Same multiset.
Input: ('aab', 'ab', 0, False)
Expected Output: False
Explanation: Different counts.
Input: ('aab', 'ab', 1, False)
Expected Output: True
Explanation: One deletion fixes the mismatch.
Input: ('Listen', 'silent', 0, True)
Expected Output: True
Explanation: Optional case-folding.
Input: ('', '', 0, False)
Expected Output: True
Explanation: Empty strings.
Hints
- A character frequency difference gives the number of insertions/deletions needed.