Skip to content

Instantly share code, notes, and snippets.

@lazywithclass
Last active March 21, 2017 04:04
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/fe0b223dc1e7dd079b80f48952ddeecd to your computer and use it in GitHub Desktop.
Save lazywithclass/fe0b223dc1e7dd079b80f48952ddeecd to your computer and use it in GitHub Desktop.
[RC Diary] Interview mock, helping a recurser figuring out how to code her ideas (-74)

[RC Diary] Interview mock, helping a recurser figuring out how to code her ideas (-74)

Helped recurser

It wasn't that easy because I had to remain concentrated all the time, to avoid saying wrong things to her.

I found this to be a really good exercise, we went from best practices for the frontend to the ones for the backend passing through session handling and how to perform calls to a third service that requires OAuth for certain calls.

Really good stuff!

Balanced parens problem

These are some balanced inputs

()(())() 
()
((()()))

while these are unbalanced

(
())
(() ()))

The function should output false if the set of parens, passed in as string, are unbalanced, true if balanced.

This is the solution

Array.prototype.pop = Array.prototype.shift
Array.prototype.push = Array.prototype.unshift

let balanced = code => {
  let parenthesis = code.split(''),
      stack = [parenthesis.pop()]

  parenthesis.forEach((current) => {
    let top = stack.pop()
    if (!top) {
      stack.push(current)
    } else if (top !== '(' || current !== ')') {
      stack.push(top)
      stack.push(current)
    }
  })
  return stack
}

Choosing paper

I went through the references section of both papers and took thoe titles that tickled my interest.

From "out of the tar pit"

I got these:

From "why functional programming matters"

I got these

I think I will read both last ones. They seem interesting enough.

Mock interviews

My problem was quite straightforward:

Given some code print only the sections that are not commented out by multi line /* */ comments

But I still forgot to apply "wishful programming", and come up with a clean pseudocode, mine actually looked like wrong JavaScript. I should get better at time management I think, that would allow me to understand that I still have time to write things cleanly, without rushing from one concept to the next.

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