Problem · String

Find Maximum Two-Digit Fragment

Learn this problem
EasyPayPayPHONE SCREEN

Problem statement

You are given a string consisting of digits. Find the biggest two-digits value that is a consistent fragment of the given string.

For example, two-digit consistent fragments of "50552" are ["50","05","55","52"], representing the numbers [50,5,55,52]. The biggest value among them is 55.

Function

solution(S: String) → int

Write a function:

class Solution { public int solution(String S); }

that, given a string S consisting of digits, returns the maximum two-digit value that is a consistent fragment of S.

Examples

Example 1

S = "50552"return = 55

The two-digit consistent fragments of "50552" are ["50","05","55","52"], representing the numbers [50,5,55,52]. The biggest value among them is 55.

More PayPay problems

drafts saved locally
public int solution(String S) {
  // write your code here
}
S"50552"
expected55
checking account