Pick Toys
Medium

Problem Statement

Given a string representing a long trail of toys, and an integer K=2, find the maximum number of toys you can pick up, given that you can only pick at most two types of toys.

Examples

1Example 1
Input:
{ "s": "abaccab" }
Output:
4
2Example 2
Input:
{ "s": "aaaaa" }
Output:
5
3Example 3
Input:
{ "s": "abcde" }
Output:
2
Loading...

Sign in to Run Code and Submit