Skip to content

Instantly share code, notes, and snippets.

@astromechza
Last active October 27, 2023 13:05
Show Gist options
  • Save astromechza/ee3a0323f50457a83929e7b1f083775a to your computer and use it in GitHub Desktop.
Save astromechza/ee3a0323f50457a83929e7b1f083775a to your computer and use it in GitHub Desktop.
Interview question

# A sample coding question to use for helping folks prepare for an interview

Other resources they may find useful: https://app.codesignal.com/pre-screen-practice - create a Developer account and do some practise questions.

Otherwise, use a google doc or coder pad to run this.

Part 1

We're working together for a company that processes long running transactions. Our program spits out a log file that looks like the following:

2023-01-01T00:01:53Z Transaction A Start
2023-01-01T00:02:53Z Transaction A End
2023-01-01T00:03:00Z Transaction B Start
2023-01-01T00:03:10Z Transaction C Start
2023-01-01T00:03:12Z Transaction B End
2023-01-01T00:03:20Z Doing things in transaction C
2023-01-01T00:03:24Z Transaction C End
2023-01-01T00:04:53Z Transaction D Start

We forgot to add metrics to our application! And now we need to take this log file and calculate the average elapsed time in seconds for all the completed transactions.

In the above example, the answer should be 28.666 rounded up to 29 seconds.

What's the worse cast computational and memory complexity?

Part 2

What changes would you make to this application if you needed to handle a very large, 100GB stream of logs?

Part 3

What would we do if we needed to calculate a moving average over time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment