Google Interview Question for Software Engineer / Developers
- 9of 9 votes
Question was "Given a pattern and a string input - find if the string follows the same pattern and return 0 or 1.- David_Maxwell November 24, 2014 in United States
1) Pattern : "abba", input: "redbluebluered" should return 1.
2) Pattern: "aaaa", input: "asdasdasdasd" should return 1.
3) Pattern: "aabb", input: "xyzabcxzyabc" should return 0.
I can think of a brute-force solution for this question where we add the character in the pattern and n length of the string to a hashmap and recurse over the pattern array and string. But is there anything more efficient? This was a pretty difficult question in my opinion.
| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm
Interview Type: In-Person
Open Chat in New Window