Problem Statement
Collection A is sorted using case-insensitive comparisons while collection B is sorted using case-sensitive comparisons. In case-sensitive comparisons, all uppercase letters come before all lowercase letters. Both collections are sorted in ascending order. The strings within each collection are distinct when compared using case-insensitive comparisons. For example, A could be {"bBa", "bbB", "BCa", "BCC"}, in which case B would be {"BCC", "BCa", "bBa", "bbB"}.
You are given a int[] indexes describing the two collections A and B. For all i, the i-th string in A is the indexes[i]-th string in B (all indices are 0-based). Return the minimal possible length of the longest string in A.
Definition
- Class:
- CaseDependentSort
- Method:
- minMaxLength
- Parameters:
- int[]
- Returns:
- int
- Method signature:
- int minMaxLength(int[] indexes)
- (be sure your method is public)
Constraints
- indexes will contain between 1 and 26 elements, inclusive.
- Each integer between 0 and n-1, inclusive, where n is the number of elements in indexes, will appear exactly once in indexes.
Examples
{0, 1, 2, 3}Returns: 1
The collection A can, for example, be {"A", "B", "C", "D"}.{2, 3, 1, 0}Returns: 2
The collection A can, for example, be {"a", "b", "Ca", "CB"}.{4, 3, 2, 1, 0}Returns: 3
The collection A can, for example, be {"aa", "aB", "Aa", "AAa", "AAB"}.{5, 2, 4, 1, 3, 0}Returns: 3
{10, 7, 5, 6, 4, 9, 8, 3, 2, 1, 0}Returns: 4