google logo
Google· SDE I

GOOGLE L3 ONSITE R1

Posted
28 Apr 2025
356 reads

Summary

I participated in an onsite interview for Google L3 where I was presented with two data structure and algorithm problems. I successfully solved a problem involving merging changelog files with version conflict resolution and a follow-up problem to parse changelog file content into a structured format.

How it went

You are two files of Changelogs with version and it's messages. You have to merge both of the files into the one. All the version values inside the changelog files are sorted in descending order.

If there is a conflict of any version between two files, merge them up and the message ordering should be consistent in accordance with ChangeLog from first files to be taken first then from the second file.

Print the changes after merging the changes.

Example : ChangeLog File1:

24.0.1

Added Export functionality Fixed the template issue.

23.0.2

Added Foreign key to template table.

ChangeLog File2:

24.0.2

Created index on template.

23.0.2

Resolved merge conflicts.

Output: 24.0.2

Created index on template.

24.0.1

Added Export functionality Fixed the template issue.

23.0.2

Added Foreign key to template table. Resolved merge conflicts.

My Approach : As initially, I was a function signature of mergeChangeLogFiles(List file1, List file2) where Pair denotes : class Pair { String versionNumber; List messages; }

So, I used a normal merge approach using two individual pointers for these two list and verified whosoever was greater with version number, gets printed first. But incase of conflict, it gets prioritized by file1 messages then by file2 for that particular version number and both indexes are incremented further.

For non-printed versions, got that covered up as well by printing them individually.

Interviewer was fine with my approach.

Follow Up : Now, I had to write a helper function to extract the text from the changeLog files in the List format.

List helper(String changeLogFile);

My Approach : Gave the approach to split the string by line break('\n') and parse each version number first, then from current index move two indices ahead so to avoid '------' string. Added the messages into the pair until a new line break occured and added it to the result. Interviewer seemed satisfied with my approach and I was able to both them.

Questions asked (2)

  1. 01

    Merge Changelog Files

    Data Structures & Algorithms

    You are two files of Changelogs with version and it's messages. You have to merge both of the files into the one. All the version values inside the changelog files are sorted in descending order.

    If there is a conflict of any version between two files, merge them up and the message ordering should be consistent in accordance with ChangeLog from first files to be taken first then from the second file.

    Print the changes after merging the changes.

    Example : ChangeLog File1:

    24.0.1

    Added Export functionality Fixed the template issue.

    23.0.2

    Added Foreign key to template table.

    ChangeLog File2:

    24.0.2

    Created index on template.

    23.0.2

    Resolved merge conflicts.

    Output: 24.0.2

    Created index on template.

    24.0.1

    Added Export functionality Fixed the template issue.

    23.0.2

    Added Foreign key to template table. Resolved merge conflicts.

  2. 02

    Parse Changelog File to List<Pair>

    Data Structures & Algorithms

    I had to write a helper function to extract the text from the changeLog files in the List format.

    List helper(String changeLogFile);

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Google recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!