1
// One Pass Counting Solution2
// 1. check cur-prev == 1 or -25 to track the length of longest continuos subtring.3
// 2. counts to track the longest continuos subtring starting with current character.4
// Time complexity: O(N)5
// Space complexity: O(1)7
public int findSubstringInWraproundString(String p) {8
final int N = p.length();10
int[] counts = new int[26];11
for (int i = 0; i < N; i++) {12
char ch = p.charAt(i);13
if (i > 0 && (ch - p.charAt(i - 1) == 1 || ch - p.charAt(i - 1) == -25)) {19
counts[idx] = Math.max(counts[idx], len);21
for (int count : counts) {