So we iterate through our array of strings dict[] we check if the word from that array got the same length as the pattern and if yes we call our made funcion check, that checks if the word and the string pattern got the same specific pattern. Fucntion check has time complexity O(N) but since the only words that can go there got the same size as the pattern the time complexity is O(K).
So the final time complexity is O(N+K)
So we iterate through our array of strings dict[] we check if the word from that array got the same length as the pattern and if yes we call our made funcion check, that checks if the word and the string pattern got the same specific pattern. Fucntion check has time complexity O(N) but since the only words that can go there got the same size as the pattern the time complexity is O(K). So the final time complexity is O(N+K)