Google L4 1st Onsite round
Summary
I had my first onsite round with Google for an L4 position. I was asked to build a program for string substitution with variable references, including a follow-up on cyclic references, which I mostly solved recursively.
Full Experience
So just few minutes back I had my first onsite round with Google for L4 position(SWE-3), The interviewer was so cooperative and humble guy from Europe. Asked me to built a program to substitute a string with given variables: #{'X':'%Z%', 'Y':'45', 'Z':'32'} #string='%X%_%Y%' #output: 32_45 earlier he didn't mentioned about variables can refer to other variables too, but later he followed up with that on which I tweaked my solution to a recursive approach. Good experience over all.
Interview Questions (1)
Build a program to substitute a string with given variables. The variables are provided in a dictionary-like structure, and the string contains placeholders enclosed in '%' characters.
Initial problem example:data = {'X':'%Z%', 'Y':'45', 'Z':'32'}
string_to_resolve = '%X%_%Y%'
Expected output: '32_45'
Follow-up: Variables can refer to other variables (e.g., 'X' might refer to 'Z'), requiring a recursive approach. Also, consider cycle detection to handle cases where variables refer to each other in a loop.