Hello All,
Recently I had a phone interview with Amazon for SDE-2 role. Unfortunately, I couldn't clear it but I wanted to share with community to see if anyone have a better solution/approach on these questions for my learning. Also, for others who are preparing for interview as a prep material.
Q1. You work in a company as an engineer. In the system, you have a lot of files (~ 50K) which contains phone number(s) in any valid format. You have given one time task, is to find all the files which has phone number in it and generate a list of it with absolute path from root. [Clarified with Interviewer - These files can be of any size with extensions (like .txt, .dat or no extension) in different folders with different hierarchy. We are only given the root.]
Q2. You are given with a string of 'a' and 'b' only in it. You can replace either 'a' to 'b' or vise-versa, as long as they are consecutive. Return [start and end index] from that string which you will replace in such a way that will give you longest seq either with 'a'(s) / 'b'(s) in the original string. You cannot modify the original string itself.
example:
i/p: "aaaaabbbaaaabbbbbbbbbbaaaaaaa"
expected out: [12,22] ## if we replace second pattern, then it will give longest seq of 'a' i.e 'aaaaaaaaaaaaaaaaaaaaa', Note: end index is not inclusive.
Q3. Give a number, return True or False if it is a power of 2.
Thank you in advance for your suggestion/approach.