String Deduplication with Window Size

Asked at Grammarly · Coding Questions · Difficulty: Medium · Last asked Jul 15, 2026

Given a string and an integer window size, remove duplicate characters so that each character appears only once. Return the new string. In the sliding window, move the window by its size each time. Test cases: input `'abacad'` with window size 2, output `'bacd'`; input `'121345'` with window size 3, output `'1345'`.

Loading the problem…