Company: DevRev
Difficulty: medium
Minimal Substrings with K Distinct Characters Problem Description You're working on a new programming language with some interesting built-ins for strings. One of the features you'd like to implement involves splitting a string into substrings with a limited set of characters. Given a string inputStr and an integer k , your task is to split inputStr into a minimal possible number of substrings so that there are no more than k different symbols in each of them. Return the minimal possible number of such substrings. Hint: Iterate over the string inputStr and try to use a Set structure to keep all letters used for the current substring. Every time when the set size becomes greater than k , it means that the last considered symbol should be the first one in a new substring. Examples Example 1: Input: inputStr = "aabeefegeeccrr", k = 3 Output: 3 Explanation: The string "aabeefegeeccrr" can be split into 3 substrings: 1. "aabee" (unique characters: 'a', 'b', 'e' - 3 distinct characters) 2. "