Problem Statement
You are given String s consisting of characters 'A'-'Z'.
You wish to delete some characters from the string, such that the characters that remain are all in non-decreasing order.
Return the length of the longest possible string that remains.
Definition
- Class:
- OrderlyString
- Method:
- longestLength
- Parameters:
- String
- Returns:
- int
- Method signature:
- int longestLength(String s)
- (be sure your method is public)
Constraints
- s will contain between 1 and 200 characters, inclusive.
- Each character of s will be in the range 'A'-'Z'.
Examples
"ABCDEFG"
Returns: 7
We don't actually need to remove any characters."GFEDCBA"
Returns: 1
The characters initially are all in the wrong order, best we can do is leave only one."ACBB"
Returns: 3
ABB is the longest.