Instantly share code, notes, and snippets.

lazywithclass/blog-post.md

Last active March 21, 2017 04:08
Show Gist options
• Save lazywithclass/e3d1e52affa3bec7dae2effbe1efff44 to your computer and use it in GitHub Desktop.
[RC Diary] Mock interviews (-94)

[RC Diary] Mock interviews (-94)

Mock interviews

Longest increasing subarray

Given an input like `[6, 7, 8, 1, 2]` it should return `[6, 7, 8]`.

magic index problem

http://algorithms.tutorialhorizon.com/magic-index-find-index-in-sorted-array-such-that-ai-i/

A good take away lesson from this exercise was that if you have to deal with array splitting (like in binary search for example), you might want to keep the original array and pass around boundaries indexes, so it's easier not to lose the position of the magic index.

String compression

"aabcccccaaa" -> "a2b1c5a3" and if the compressed string is longer return the original.

Print all possible n pairs of balanced parentheses.

For example, when n is 2, the function should print `(())` and `()()`, when n is 3, we should get `((()))`, `(()())`, `(())()`, `()(())`, `()()()`.

http://blog.gainlo.co/index.php/2016/12/23/uber-interview-questions-permutations-parentheses/

Pseudocode for this could be

``````f(n) = for i in range(n):
for l in f(i):
for r in f(n-i-1):
results += "(" + l + ")" + r
return results
``````

Find unique int among duplicates

https://www.interviewcake.com/question/java/find-unique-int-among-duplicates

The idea here is to recursively compare max subsets of array

The description should be something like "Different types of tests, how to create and run good tests, best practices, available tools for testing".

The important things to focus on IMHO are

• why should I test? And,
• how do I write good effective tests?

One should test to reach the objective of pushing into production and then leaving to have lunch. One should arrive to this kind of confidence in their architecture and testing solutions.

To have that tests should be written, and a continuous delivery process started. But

• how good does a test should be written to be good enough?
• how many tests is enough?
• have I covered all the branches?

Read Uncle Bob take on mutation testing

http://blog.cleancoder.com/uncle-bob/2016/06/10/MutationTesting.html

Plans

• Cerebro
• prepare test talk "Different types of tests, how to create and run good tests, best practices, available tools for testing" for March 1 at 2pm
• project lamp
• still need some attention needed for timsort, radix sort, dijkstra algo
• chapter 1 and 2 of the little schemer in Clojure
• reflect on first two weeks of RC