c solution
Code

# Code
```c []
void init_arr(long long* arr,int arrSize,bool flag){
    // 確認是3還是4
    int mod = 1e9+7;
    arr[0]=arr[1]=1;
    arr[2]=2;
    arr[3]=4;
    for(int i=4;i<arrSize;i++){
        arr[i] = (arr[i-1] + arr[i-2] + arr[i-3])%mod;
        if(!flag) arr[i] = (arr[i] + arr[i-4])%mod;
    }
}
int countTexts(char* pressedKeys) {
    int n = strlen(pressedKeys),mod=1e9+7;
    if(n==1) return 1;
    int size = 100001;
    long long* three_text=calloc(size,sizeof(long long)); // 連續 1、2、3的字元所對應可以產生出的結果
    long long* four_text = calloc(size,sizeof(long long)); // 記錄可以產生出四種結果的'7'、'9'
    init_arr(three_text,size,true);
    init_arr(four_text,size,false);
    int start_idx = 0, end_idx = -1;
    long long total_combine = 1;
    int ans;
    while(start_idx<n){
        while(end_idx+1<n && pressedKeys[start_idx]==pressedKeys[end_idx+1]){
            end_idx++;
        }
        int length = end_idx - start_idx + 1; 
        if(pressedKeys[start_idx]=='7' || pressedKeys[start_idx]=='9'){
            total_combine = (total_combine * four_text[length])%mod;
        }else{
            total_combine = (total_combine * three_text[length])%mod;
        }
        start_idx = end_idx+1;
    }
    ans = (int)total_combine;
    return ans;

}
```
['C']