Level: Junior-Level
Round: Full Journey · Type: Coding · Difficulty: 6/10 · Duration: 120 min · Interviewer: Neutral
Topics: String Manipulation, Hash Table, Sliding Window, Frequency Counting
Location: San Francisco Bay Area
Interview date: 2026-01-15
Question: Given an array of strings, maximize the number of palindromic strings by swapping characters between different strings.
Question: Find the minimum length subarray containing k distinct numbers.
Problem Description:
Given an integer n and a string array arr of size n containing lowercase letters. You can perform the following operation any number of times: Choose two different strings and swap one character from each.
The goal is to maximize the number of possible palindromic strings in arr after performing the operations.
Example: Input: arr = ["pass", "sas", "asps", "df"] Output: 3
Idea: Fix the length of each string. Characters can be globally allocated. First, calculate character frequencies, then count pairs and singles. Finally, allocate based on length.
Problem Description: Given an integer array and an integer k, find the size of the smallest subarray that contains k distinct integers.
Approach: Use a hashmap to count number frequencies and a sliding window to check for k distinct numbers.