Find all pairs of characters in a string that are the same (nested loop).
Difficulty: Medium
Phase: 6 · Mixed Logical Challenges
XP Reward: 20 XP
Topics: Mixed Logical Challenges, Medium
Supported Languages: Python, JavaScript, C, C++, Java
Problem Description
Given string S on line 1 and integer K on line 2, find the length of the longest substring containing at most K distinct characters. Input Format: Read input from standard input (stdin). Output Format: Print the result to standard output (stdout).
Constraints
- -10^9 <= N <= 10^9
Examples
Example 1
Input: eceba 2
Output: 3
Explanation: Sample execution for input eceba 2