โ† Optum (UnitedHealth Group) questions

RegEx and Anagrams

Filed under Optum (UnitedHealth Group)

Free read 2 of 3

Determine if spaces and capitalization matter for the anagram problem.

The question

Write code to solve string manipulation problems involving regular expressions and anagram verification.

Constraints

  • Strings consist of lowercase English letters or standard regex wildcard characters.
  • 1 <= length of strings <= 10^4

Examples

Input
s1 = "listen", s2 = "silent"
Output
true
Why
Both strings contain the exact same character frequencies, making them anagrams.

Approach

  1. Determine if spaces and capitalization matter for the anagram problem.

Solution

O(N) time, O(1) space

Python
from collections import Counter

def is_anagram(s1, s2):
    if len(s1) != len(s2):
        return False
    return Counter(s1) == Counter(s2)

Tips

  • What they are testing: Test edge cases like empty strings, strings of different lengths, and case sensitivity.
  • Common mistake: Using inefficient sorting for anagrams instead of character frequency counting (O(N) vs O(N log N)).

Related Optum (UnitedHealth Group) questions

Collected from public candidate posts and coding forums. Updated Nov 2026.