FazeelUsmani / Amazon-SDE-Preparation

This repository includes all the interview preparation questions for Amazon SDE role
https://practice.geeksforgeeks.org/batch/Amazon-Test-Series
1.15k stars 295 forks source link

Create 07 matchSpecificPattern.cpp #74

Closed Juro221 closed 3 years ago

Juro221 commented 3 years ago

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)