Skip to content

Instantly share code, notes, and snippets.

@lazywithclass
Last active April 14, 2017 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazywithclass/e544644a3bcaf0958accb6679f026ab8 to your computer and use it in GitHub Desktop.
Save lazywithclass/e544644a3bcaf0958accb6679f026ab8 to your computer and use it in GitHub Desktop.
[RC Diary] Interviews (-46)

[RC Diary] Interviews (-46)

Interviews

Code

Today I've learned that I should apply my interview tools

  • can I relax some of the contraints on the result?
  • can I approach it in more time / more space?
  • can I assume I have crucial functions that would lead me towards a solution?

everytime I get stuck. Even when I'm baffled by the complexity of a problem: for example today I was given a mathematical problem, that was presented more or less like:

You are given f(x) = ( a * ( b - x ) ) % m, how would you go and implement a function that tells you the length of the repeating sequence?

So, the key points here are two:

  • f(x) = ( a * ( b - x ) ) % m could be simplified as f(x) = x % m
  • % works like this 0 % 3 == 0, 1 % 3 == 1, 2 % 3 == 0, 3 % 3 == 0, 4 % 3 == 1

it is clear now that % repeats a sequence. So that was the key to go through the problem.

Architecture

I've been asked to show how I would implement an url shortener, I feel like it went better than the last time. Last time it was in an interview, I think 1.5 years ago, so many thing changed since then.

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