Showing posts with label good design. Show all posts
Showing posts with label good design. Show all posts

Friday, May 1, 2020

Case study: Lowest common ancestor

May 1, 2020

Introduction


It is the first interview I got the whole week. I worried about interviewing.io financial situation, and free anonymous interview is no longer affordable since some one has to pay the bill. A lot of layoffs last two months, people are flooding in job market for software engineer positions.

Mock interview case study



Here is the code.





Discussion we had on the mock interview:

The clever part is to return two things in recursive function. One is to find lowest common ancestor, if it is found then it should be returned; Second one is supporting role to calculate the node found. As we know, the node can be root node or any child node in binary tree. Using total nodes found is the technique to make it easy to identify the edge case: root node is one of nodes p or q, then another node is in subtree nodes.

One thing to make it more readable is to replace checking of return TreeNode null with node's count comparison to value 2 instead.

Interviewer feedback


Interviewee - an ex-facebook engineer



His second algorithm is also bug-free, here is the link.

Actionable items


May 25, 2020

The interviewee is young and top talent engineer. After the mock interview, he saw my feedback, and then he decided to get connected on interviewing.io. I should ask a linkedin.com connection from him, so I can track his career success later on.

Thursday, December 10, 2015

Coding principles, good/bad design

Dec. 10, 2015

Julia spent time to work on legacy code she wrote last few years, she chooses the good design this time. Share 3 things: 

1.      One of favorite quotes by Sir C.A.R. (Tony) Hoare (quick sort algorithm inventor in 1959/1960) 
"Inside every large problem, there is a small problem trying to get out." 

2.      One of favorite talks: 
Less code = More Software
Peter Somerland

3.      And her favorite verse of design from Peter Somerland: 
Bad design vs good way: 
one way is to make it simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. 

 The first methods is far more difficult.