As reported: HSBC Trainee Software Engineer, campus hiring (2026), technical interview (~35–40 minutes, live coding on JDoodle). One of three simple coding questions: given a string of digits, find the maximum two-digit number formed by consecutive digits — for
"05523"the answer is 55. Follow-ups on complexity and edge cases.
Given a string s of decimal digits, consider every pair of adjacent digits s[i]s[i+1] as a two-digit number (a leading zero is allowed: "05" is 5). Return the largest such number.
Example 1
s = "05523" -> 55 (pairs: 05, 55, 52, 23)
Example 2
s = "10" -> 10
Example 3
s = "00000" -> 0
Constraints: 2 ≤ s.length ≤ 10^5; s contains only digits 0–9.
Code runner format: one JSON value per line: s. Implement maxTwoDigit(s); the harness prints the number.