Saturday, January 16, 2016

Cracking the Coding Interview (Part 1, 2 of 2)

January 14, 2016
Take notes about the video 

Cracking the Coding Interview (Part 1 of 2)

software programmer

Coding, problem solving, analytical skills and intelligent. 

Look for your aptitude, but not just your knowledge, for those top companies. 

Entrepreneur: start a marathon training group

The valuation of technical questions are relative to other candidates. 

How You Are Judged
How did you do RELATIVE to other candidates on the SAME question? 

More detail, coding questions, how fast you come out solution, how good your algorithm, how clean your code, how buggy your code. 

PM Roles (program manager, project manager)
. Communication Skills
. User-Focused Thinking
. Passion for Technology 
. Analytical Skills
. Technical Skills ( position dependent )

How We Review Resumes
1. Pull resume out of giant stack
2. Spot-check: company names, positions, projects, schools. 
3. Skim bullets to see if you've written real code
      reject   interview
4. Go to next resume & whine about how many more you have left. 

"Glanced at," not read, 15-30 seconds

Behavior questions:
Communication Goals
. Answer the question. 
. Deliver a *good* answer. ()
. Communicate well. 

Preparing for Behavioral Qs
. Create Preparation Grid for Projects
                                  OS Project           Amazon Intern
Enjoyed
Hated
Most Challenging
Hardest Bug 

Behavior Grid [for PM & less tech. roles]

Two structures:
1. First words is the answer. 
2. Situation, Action, Result   S. A. R. 

Technical questions:
Coding algorithms - study very well 
Out-of-schools 

They are not testing your knowledge. 

Practice solving questions. 
- Don't memorize!
- See: CtCI & CareerCup.com
. Push yourself!

Data strucutres
How to implement 
When to use (pros / cons)
Linked Lists         Stacks   Queues
Trees                   Tries      Graphs
Vectors                Heap      Hashtables

Algorithms
Implementation
Space vs. Time complexity 

Quick Sort                                 Merge Sort 
Tree Insert / Find                       Binary Search 
Breadth-First  Search                Depth-First Search 

Concepts 

Not just a concept - know how to code!

Threading   System Design & Scalability         Memory Management 

Recursion   Probability + Combinatorics           Bit Manipulation

Big O time 

How to learn CS Fundamentals:
Necessary for "elite" tech companies 
MIT Open Courseware
Freshman / sophomore level DS & Algo courses
Books 
- CLRS (Algorithms)


Part 2 of 2  - probably here? 

Types of "Serious" Questions
1. Product Design Questions
2. Estimation Questions
3. Software Engineering Questions
- Coding & Algorithms
- Object Oriented Design 
- Scalability 
- Factual / Trivia / Language-Based

Problem Design Qs: Approach 
1. Ask questions to resolve ambiguity
2. Understand the user
3. Structure the problem
4. Solve piece by piece

Estimation Questions:

It is not important to know the answers. About two things, problem solving and basic quantity skills. 

How much Gmail business revenue annually? 

The way to approach questions, 
Ask questions, gmail or gmail.com
Revenue or net sales 

Find structures: 
1. How many gmail acount users?
2. Estimate how much dollar value per click
3. How many clicks

If I can guess 3 numbers we have, I can multiply them and get answer for you. 

How do you figure out how many Gmail account users? 
Break down, make some assumptions, 

Estimation Qs: How to Approach
1. Ask questions to resolve ambiguity
- Don't make assumptions (yet)
2. Outline / Structure Your Approach 
3. Break down the components
- Assume numbers when necessary
- State assumptions explicitly 
- Round numbers to make your math easier

How many population? 80% uses gmail
Make reasonable guess

Take notes when you do it

Coding algorithms:
Ask questions - what the people are looking for
Talk aloud - 

How to Solve Tough Problems (7:53 /22:56 - ? )

1. Ask Questions!
- Questions are more ambiguous than they appear

2. Talk out loud
- Show us how you think 

3. Think critically 
- Does your algorithm really work? What's the space and time complexity? 

4. Code slowly and methodically
- It's not a race. 

Make too many mistakes, take too long, don't try to race it. 
If your code is done, test your code; make sure that it really works

Find the bug, do not just fix the value; find what is wrong. 

What does mean to write a good code? 

What does a "good coder" do? 
. Code in top-left of whiteboards
. Pseudo code first (if necessary)
. Be methodical. Don't try to rush. 
. Reasonably Bug Free
- Thorough testing (and careful fixing)
- Check for error conditions
. Clean coding
- Use other functions
- Good use of data structure (define own if useful)
- Concise and readable 

Algorithm Qs: Pattern Matching (13:10/22:56)

Q: Write code to reverse the order of words in a sentence. 
"dogs are cute"
"cute are dogs"

Similar to: reverse characters in a string. 
"dogs are cute"
"etuc era sgod"

A: Reverse full string, then reverse each word. 

Another approach: Simplify and generalize

Q: Design algorithm to figure out if you can build a ransom note (array of strings) from a magazine ( array of strings). 

Simplify: what if we used characters instead of strings? 
  -> Build array of characters frequencies. 

Generalize: how we can extend answer to words? 

A: Build hashtable from word to frequency. 

Next Approach: Base case & Build 
Q: Design algorithm to print subsets of set
{a, b, c} -> {}, {a}, {b}, {c}, {a,b}, {a,c}, {b, c}, {a, b, c}

S({}) -> {}
S({a}) ->{}, {a}
S({a,b}) -> {}, {a}, {b}, {a,b}
S({a,b,c}) -> ?

A. Build S(n) by cloning S(n-1) and add n to the cloned sets. 

Final approach, data structure brain storm

Q: There are 10^10 possible phone #s. Explain how you could efficiently implement 
assignSpecificNum(num) and assignAnyAvailableNum(). 

Array (sorted)? Too slow to remove num. 
Linked list? Too slow to find specific num. 
Hash table? Can't iterate through free nums. 
Tree? Ah-ha!  Binary search tree

Evaluation is relative. 

Top 10% - always get A, does not matter how hard the problem is. 

. Write real code - 
. Don't rush 


Leetcode 314: Binary Tree Vertical Order Traversal

January 16, 2016 

First time after 9 years, I installed Eclipse, J2SE, and then, set up Java developer IDE Eclipse, ran the first Java program. Such a great ride to enjoy Java programming. Still remember that in 2006 - 2007, spent over 10 hours daily to read/ run/ maintain software using Java programming language, when I worked for a small startup called Siva Corp Inc. in the city of Delray Beach, Florida, USA. 

Just bring all my good memory back about programming using Java.


http://buttercola.blogspot.ca/2014/09/leetcode-n-queens.html

Leetcode 314:
https://github.com/jianminchen/Leetcode_C-/blob/master/BinaryTreeVerticalOrderTraversal_314.java

Another blog using C++,

http://buttercola.blogspot.ca/2014/12/facebook-print-binary-tree-in-vertical.html

Google hiring Best Practices - How to interview others?

 January 12, 2016

GoogleHiring Best Practices by Allison Watson

Take some notes about the presentation:


4 key criteria



1. Intellectual curiosity, Problem solving: 
very curious, understand problems; using 
hypothetical questions or behavior questions, really see how people break down the problem, can they see through, do they ask right types of questions

2. Technical skills, abilities


3. Leadership, not necessary people leadership, willing to take risks, having ownership


4. People are nice, you want to work with them. Do they want to engage with people? Work with part of team? Someone you can sit with 3 hours in the airport, wait for a flight and get along with them? Good sign that people can think good with the company. 


5. Diversity - try to improve on this. Diverse workforce to reflect them. 

A lot of consensus to make hiring decision


Questions: 


1. How Google keep the culture up when company grows? (Video time 7:00 - 9:00)


Always look for 
people who are curious, engaged, that is number one.

Make sure that we can offer them opportunities.

A lot of people move not for money, not because of money, move because of opportunities to grow, something interesting and challenging; get people always challenging themselves, improve themselves. Give them opportunities to grow, allow them take risks, fail, and then take more risks, and then you tend to find them always engaged.

In summary, what other values, fundamental values, stick to those values. Look for people embody the same thing. 

2. How do you know the person is going to do well? (video time 9:00 - 11:32)


Explain the Jahn-Teller effect, flip side of effect.

For example, someone comes in the room, smiling all the time, really nice; so you try to convince yourself why to hire this person. In the positive frame or mind.

However, do the opposite, people came from some university, look for reasons not to hire them. Be very conscious on that.

First thing as an interviewer is always thinking or rethinking, and checking, and asking several questions. Something seems off, keep asking, keep checking. Do not do it by yourself. Try to get at least 2 or 3 perspectives. And ideally, some one is not completed involved, have discussion afterwards.

Get 3 people in committee to discuss, objective,

what are the flags: be convinced.
Check that are you fair, not some one just likes you. Check that the person is good for company, good for the job.

Are there any place you can mitigate? Better to get right one. If all three of you are so so, do not do it. You are better to get convinced, and get a long time and get right person.

3. Do not do panic interview


Can you tell last project successful? A lot of questions followed. 

Hypothetical question: You can see the reasoning, how they will approach the work. But behavior question, a good story-teller will do better, (may not be a good fit for the job)

4. How to shortlist the applicants? 

The ways to shortlist, two things, you create job spec, seem to get a lot of unrelated resumes; Change the other job spec. Relevant job skills, is CV very jumpy? Make sure that this person can be committed, if the person moves a lot of jobs. 

Try to see the achievements. Do a lot of phone screen, quick call; 5-10 minutes, you can quickly get what you want. 

Huge emphasis on employee referrals. Recommendation and network. 

5. How to make sure the managers do the good work on hiring? 

Train them; what criteria we are looking for. 
Shadow interviews. Make sure that they are understanding process. 
Ask to write feedback, 

Tuesday, January 12, 2016

Leetcode 51: N - Queen problems

January 12, 2016

Encourage myself to write blogs about leetcode questions. The following talk encourages me a lot. 

https://www.youtube.com/watch?v=R22dJ7bn-pU&list=PLgYNPs-V9YFPqcnEvbIy5hFE40BjxMbjw&index=2
Hiring Rockstars by Roger Philby

the person likes to write, and then the person must love to read, and then the person must be very curious and intellectual. 

So, Julia likes to build up a good habit to write, and then, to read, and to be curious, and to be intellectual. 

Julia is working on recursive function design, how to handle N-Queen problems. After 6 months, she totally forgets how to solve the problem; So, she continues to read more blogs about this algorithm. 
Review the algorithm again. The following blog gives a good explanation, help me understand the algorithm better.
 
blog1 (Java programming language): 
http://blog.csdn.net/linhuanmars/article/details/20667175

Amazed that a person can work on algorithms problems and finish over 300 questions/year, people love algorithms and they must know the power of algorithms to save time and improve efficiency at work. 


http://buttercola.blogspot.ca/search/label/Leetcode
http://buttercola.blogspot.ca/2014/09/leetcode-n-queens.html
Leetcode 314:
https://github.com/jianminchen/Leetcode_C-/blob/master/BinaryTreeVerticalOrderTraversal_314.java

Julia likes to work on the analysis of the algorithm, this pseudo code in the blog may help her quickly recover, from nervous to get familiar with the algorithm. 


The following blog is well-written, and Julia should write a similar solution using C#, to express her appreciation of good variables names, good analysis. (Rating: 10 from 1-10) 

https://polythinking.wordpress.com/2013/02/27/leetcoden-queens-i-and-ii/


It is fun to read solutions in C++/Java.


Write another version of N-Queen problem in C# to entertain. 
https://github.com/jianminchen/Leetcode_C-/blob/master/51NQueenProblem_B.cs

Good advice from the blog 1: 基本上大部分NP问题的求解都是用这个方式,比如Sudoku Solver,Combination Sum,Combinations,Permutations,Word Break II,Palindrome Partitioning等,所以只要把这个套路掌握熟练,多练习. 

Feb. 2, 2016 It is also a DFS algorithm. 

Sunday, January 10, 2016

Leetcode algorithm 160 -170 study

January 10, 2016


Write a lot of code. It is the only way to improve and become a better programmer.

Julia likes to read blogs related to Leetcode algorithm problems, and then she learns how to solve problems.

In other words, 做程序员, 需要多看别人的代码. 向同行学习.

Leetcode questions 161 - 170

August 22, 2015

161 One Edit distance
http://www.danielbit.com/blog/puzzle/leetcode/leetcode-one-edit-distance

http://www.meetqun.com/thread-2854-1-1.html

162 Find Peak Element


need to write first C# implementation for this problem.

163 Missing Ranges

http://bookshadow.com/weblog/2014/12/14/leetcode-maximum-gap/

Julia, please practice this C++ code, and get some idea how advanced C++ works. (January 10, 2016)
http://ask.julyedu.com/question/213


165 Compare Version Numbers

166 Fraction to Recurring Decimal

167 Two Sum II - Input array is sorted

168 Excel Sheet Column Title

169 Majority Element

Friday, January 8, 2016

Wednesday, January 6, 2016

Divide and Conquer: Preorder traversal of ternary tree


January 6, 2016
重温一道关于树遍历的题目, 在新年开始的第一个星期, 鼓励自己, 加油! 多写代码, 多练习.

Be humble, learn from her mistakes in 2015. Julia is learning how to solve "divide and conquer" - write a perfect recursive function - without bug in base case - recursive calls. 

Her lessons for recursive function design, divide and conquer solution in 2014, 2015:

1. Do the work for root node, but do not do the work for its children; In other words, a subproblem can be handled by a recursive call. 

2. Do not repeat base case 'if' clause - a checking afterwards in the recursive function call. Not necessary, except trying to use less stack. 

Julia, recursive function design is like dealing with a family - single parent with children; show the work how to handle root node, that is almost done. Let recursive function to take care of children, do not do the work for children nodes. For example, binary tree, 2 children, call recursive function twice; Ternary tree, 3 children, and then, use 3 recursive calls. 

Once again, "Do not do the work for children directly". 

Action items:
1. Work on Leetcode questions again and start with simple questions.

Binary Tree Preorder traversal of ternary tree
More reading about ternary tree:
  https://en.wikipedia.org/wiki/Ternary_search_tree

Friday, January 1, 2016

Favorites of top 10 rules for success

Dec. 31, 2015

 Stayed up to last minute of 2015, 12:00am, watching a few of videos about top 10 rules for success, and then, think about putting together a blog to share, for a successful year 2016.

  Top 10 rules for success

1. Jessica Alba
2. Oprah Winfrey
    No. 5, Run the race as hard as you can
    Julia's favorite, do not look at others, things you cannot control; focus on yourself
    25 years talk show, hundreds of talk show failed.
 
    9. Stay grounded

3. Bill Gates
    No. 7  Ask for advice 
    Blind spot concern
    No. 8 Pick good people
    No. 9 Don't procrastinate
    School, last 2 days study for exam
    But in business world, it is not good.
    No. 10 Have a sense of humor

Warren Buffett
    No. 5 Have a margin of safety
    No. 7 Schedule for  your personality

Jack Ma
     No 1. Get used to rejection
     No. 9 Don't complain, look for opportunities
     No. 2 Keep your dream alive
     No. 3 Focus on culture
     Not just money, to help others
     No. 5 Get inspired
     No. 7 Have a good name
     No. 8 customers are #1
     Share holders will leave quickly if there is bad thing happens

Jeff Beco
     No. 1 Have no regrets
     80 years old, think about things you try in young age. Internet, if I fail, no regret.
     No.2  Follow your heart not your head
     No. 3 Invest more in the product then marketing
     No. 4 Pick a good name
     No. 5 Stand for something
     No. 6 Focus on the customer
     No. 7 Focus on your passion
     No. 8 Build a culture
     No. 9 premium products at non-premium prices
     Kindle, product - no profit, but user uses it, make money
     No. 10 take a risk

Larry Page
     No. 2 Don't be afraid of failure
     work on 10 years
     leadership training - fail fast
     Take some risk, encourage to take more risk
     No. 3 Stay organized
     No. 4 Concentrate on the long term
     tooth brush test ( twice a day)
     gmail/ youtube
     double the revenue on youtube, since a lot of people use it. But at the begining, spend a lot
    No. 5 Have a good idea
    No. 6 Solve bigger problems
    No. 7 Take on challenges
    No. 8 Don't settle
    other people do not tell
    Be an expert in all areas
    Search algorithm, spent 3-4 years on it, before Google has over 100 people work on
    No. 9 Adapt to changes
    No. 10 Follow your dreams
    anxiety -> dream
    about school, computer error about admission etc. /irational worry, then anxiety, had a dream:
    download entire web to a small computer lying around ->
    after dream, stay up a few of hours, work on algorithms ->
    set up a few weeks, thought at the beginning vs 1-2 years work ->
    keep links -> not all web pages -> rank of pages -> google
    Share the story of his personal dream -> developed a top of world company and technology - Google

   Michale Jordan
       No. 1 Keep working hard
       No. 2 Ignite the fire
       nothing can stop me
       No. 3 Be different
       No. 4 Fail your way to success
       Fail over and over and over again.
       No. 5 Have high expectations
       No. 6 Be positive
       bad thing/good thing mixes, no such thing called bad thing
       No. 7 Be who you were born to be
       Encourage to fail
       Take everything you are given,
       Not about shoes, it is about where you choose to go
       No. 8 Have a vision
       Mentally strong
       No. 9 Stop make excuses
       No. 10 Practice (no need to think when in the game, situation met before)
       At that moment, you do not have to think

Kobe Bryant
        No. 1 Make sacrifices
        No. 2 One move at a time
        How do I prepare? One piece a time, start from a small step
        No. 3 Trust your skills
        how to face criticism? Pressure?
        No. 4 Use your scars as a weapon
        open up to them
        No. 5, Focus on each day
        Do not think about the final result, focus on each day -> training, conditioning, ...
        No. 6 Don't be afraid confrontation
        Cannot please everyone
        Even hurt your feelings, tell something: small thing, like food in your teeth
        No. 7 Be competitive when it's hard
        No. 8  Just keep going
        career -> not chase championships
        good/bad moments, things will work out
       No. 9 Thrive on being an outsider
       No. 10 Compete with yourself
       a story about practice, 800 times, young but mature, weight training, conditioning

     January 2, 2015

Vinod Khosla's Top 10 Rules For Success (22 minutes, co-founded Sun Microsystems from 1982 to 1984)

https://www.youtube.com/watch?v=MsGgZp_PAzM
No. 1. Be pesistent
No. 2. Keep innovating
No. 3. Add value
No. 4. Have the guts to follow your beliefs
No. 5 Try and fail, but don't fail to try
No. 6 Transcend what's traditional
No. 7. Shake things up
No. 8. Build a great team
No. 9. Dare to be great
No. 10. Be brutally honest

Facebook Documentary - Sheryl Sandberg's Top 10 Rules For Success

https://www.youtube.com/watch?v=qKRB8n6PULQ
No. 1 Have impact
No. 2 Think big
No. 3 Go for growth
she joined google when there were only 200 people.
She worked for a person 23 years old.
Care less about level, but about growth.
No. 4 Communicate authentically
There is no truth. Your truth, my truth. It is objective.
Walk in room, say what you believe. Give people room to authenticate, give out their thoughts.

No. 5 Hire big
Hire for then, not just now. Then happens quickly. 
Hire overqualified, hire new graduate. 

No. 6 Don't just talk, really listen!
No. 7 Take responsibility
No one has complete control.
Learn to take responsibility. Late for work, it is not for traffic. But you do not consider the traffic issue.
No. 8 Measure results, not face time
Focus on result, not face time. But if you focus on face time, you reward face time. 
People work hard, but may not focus on result.
No. 9 Find something you really believe in
No. 10 Careers are not ladders, but jungle gyms

Jeff Weiner's Top 10 Rules For Success

https://www.youtube.com/watch?v=do9jIFIFj08&list=PLiZj-Ik9MmM0VWRGYCfuUCdyhKfU733WX&index=102

Reference videos:
Michael Jordan's Top 10 Rules For Success

Kobe Bryant's Top 10 Rules For Success

https://www.youtube.com/watch?v=5Nd_nUhUj2M

More watching:  ( January 2, 2015 )
Vinod Khosla: Failure does not matter. Success matters.
https://www.youtube.com/watch?v=HZcXup7p5-8

Note to laugh: Strategy to get greencard: Convince them, otherwise, confuse them.
Notes: come out your priority, and then measure
in 1990s, 25 dinners with kids /month, try to achieve them; means, no sports out with friends in dinner time.

January 21, 2016 (20 minutes talk - after 10 rules, there are 8 minutes talk about her projects at Google, nice sharing)

Marissa Mayer's Top 10 Rules For Success

https://www.youtube.com/watch?v=02zYZ-JB2zQ

http://www.businessinsider.com/google-cfo-ruth-porat-success-secrets-2015-12

January 31, 2016
Tony Hsieh
https://www.youtube.com/watch?v=49kJE4HJb_w
1. Chase the vision, not the money (
    things like to do, and does not make a dime in 10 years / and let the money follows;
    do not chase paper, chase dream
    Entrepreneurs:
    What would you be passionate about doing for 10 years even if you never made a dime?
    )
2. Hire the right people (
   technical: meet the bar, but, hang out with? if the answer is no, then ...
   work life balance/ so much time at work, better enjoy it  
   - good one/ medium one: strong culture - 10 core values - does not matter what value you are
   - no judgement of values - but you have some values - figure out what values you are  
   )
3. Let your customers do marketing for you. (buy exposure /ads etc., make customer happy - word of mouth)
4. Think long term
5. Do thought experiments
6. Form close bond with your coworkers
7. Have self-confidence
8. Celebrate each person's individuality
9. Maximize customer experience (360 day return policy, contact information - opposite information, low technology, unsexy - phone calls)
10. Just be happy (lose everything, still be happy)