moengage logo
Moengage· Senior Software Engineer

MoEngage | SSE | Round1

Posted
5 Dec 2024
465 reads

Summary

I participated in a coding round for the Senior Software Engineer position at MoEngage, where I was tasked with solving a complex data processing problem involving log files to identify and count unique drivers for specific city visit triples.

How it went

During my Senior Software Engineer interview at MoEngage, the focus of the round was a challenging coding problem. I was given a scenario involving a large log file that tracked driver movements across various cities with timestamps. The core task was to extract 'triples' – sequences of three consecutive cities visited by a driver, ordered by timestamp – and then count the number of unique drivers associated with each distinct triple. This required careful parsing, grouping, sorting, and aggregation of data from the log file. The problem presented a good test of my data processing and algorithmic skills.

Questions asked (1)

  1. 01

    Count Unique Drivers for City Triples in Log File

    Data Structures & Algorithms · Hard

    Suppose you have a big text log file and there are three columns:

    • Name
    • City
    • Timestamp

    Example log data:

    Name   City   Timestamp
    John   city1       t4
    Bob   city1       t3
    John   city2       t1
    John   city3       t3
    Bob   city3       t2
    John   city4       t2
    Bob   city4       t1
    

    The first column is a driver name, the second is a city name, and the final is a timestamp (32-bit integer).

    This log file maintains a history of drivers.

    We define a "triple" as a tuple of three consecutive cities a driver has been to that are ordered by timestamp.

    Suppose t1 < t2 < t3 < t4, then we will have the following triples:

    • for John, we have: (city2, city4, city3), (city4, city3, city1)
    • for Bob, we have: (city4, city3, city1)

    Write a program to output all the triples in the file and for each triple, output the count of unique drivers that have been to that triple.

    For the example input, the output would be

    (city2, city4, city3) 1
    (city4, city3, city1) 2
    

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Moengage 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!