Below is the code where I have to check a specific character in substring of string. How can I decrease its complexity, as I use three `for` loops but want to do it in two or one loop?

```c
int main(void) {
    int i, j, k, t, n;
    scanf("%d", &t);
    while (t--) {
        int count = 0;
        scanf("%d", &n);
        char a[n], ch;
        scanf("%s %c", a, &ch);
        for (i = 0; i < n; i++) {
            for (j = i; j < n; j++) {
                for (k = i; k <= j; k++) {
                    if (a[k] == ch) {
                        count++;
                        break;
                    }
                }
            }
        }
        printf("%d", count);
    }
}

```