Solve substring and access-log problems
Problem 1: Longest Uniform Substring with Limited Changes
Given a string s consisting of uppercase English letters and an integer k, you may replace at most k characters with any uppercase letter. Return the maximum length of a contiguous substring that can be transformed into a string of identical characters after at most k replacements.
Problem 2: Detect Cross-Day URL Changes for the Same User
You are given two web access logs, one for each day. Each log is a list of records in the form (user_id, url). Determine whether there exists at least one user who appears in both days and has visited different URLs across the two days. If a user appears multiple times in a day, consider all URLs they visited on that day. Return true if such a user exists; otherwise return false.
AI interview prep
Core dilemma
For Problem 1, the core dilemma is balancing the need to find the longest possible uniform substring against the constraint of limited character replacements. For Problem 2, it's efficiently identifying users and their distinct visited URLs across two datasets while handling potential duplicates and varying data volumes.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Solve substring and access-log problems
Problem 1: Longest Uniform Substring with Limited Changes
Given a string s consisting of uppercase English letters and an integer k, you may replace at most k characters with any uppercase letter. Return the maximum length of a contiguous substring that can be transformed into a string of identical characters after at most k replacements.
Problem 2: Detect Cross-Day URL Changes for the Same User
You are given two web access logs, one for each day. Each log is a list of records in the form (user_id, url). Determine whether there exists at least one user who appears in both days and has visited different URLs across the two days. If a user appears multiple times in a day, consider all URLs they visited on that day. Return true if such a user exists; otherwise return false.