int (char @NotNull [] buffer, char symbol, int fromIndex, int toIndex) { if (fromIndex < 0) { fromIndex = 0; } for (int i = toIndex - 1; i >= fromIndex; i--) { if (buffer[i] == symbol) { return i; } } return -1; }