Monday, November 30, 2020

Dan Croitor: Interviewing for Googleyness at Google

 Here is the link. 

In this video I explain Google’s 10 Things (Core Values / Leadership Principles) and some insight into Google’s structured hiring process - for the behavioral part in particular. Contains screenshots with examples and advice. It is structured in 4 parts: A. Mission & Ten things we know to be true (Google’s 10 Core Values / Leadership Principles) 1. Focus on the user and all else will follow. 2. It’s best to do one thing really, really well. 3. Fast is better than slow. 4. Democracy on the web works 5. You don’t need to be at your desk to need an answer. 6. You can make money without doing evil. 7. There’s always more information out there. 8. The need for information crosses all borders. 9. You can be serious without a suit. 10. Great just isn’t good enough. B. Two most important things in a recruit, behavioral questions and how to prepare (STAR method) Googleyness. The first thing they measure here is cognitive ability, for example, they’ll ask you: Tell me about a tough problem you solved, how did you solve me, walk me through it. Preparation: 5 stories (full story + shortened into: situation, task, actions, result) + 3 x answers to 20 most common behavioral questions - examples in the video But one more highlight here in terms of leadership - or at least one more interesting keyword - is emergent leadership. I noticed various Google HR leaders referincing it throughout the years; whta does this mean: it’s essentially your ability to step in when there is a peoblem and step out when they are no linger needed. Would be great if you could also make this stand out in one of your prepared stories. C. Supercharge your resume with some tips; Read your CV in 6 seconds. Official advice on structure and more. And last but not least, and this should go without saying, typos in your resume won’t probably disqualify you, but you can be sure they will have a negative impact, so be sure you triple check it and ideally as a friend to review it for you. D. Best way to pass the screening round; hiring process Referrals. Apply through their jobs website. Google’s jobs website is between the very best. Google’s structured hiring is particularly efficient at creating a great applicant experience Sources and interesting reads: The list of behavioral questions shown: Data structure hiring at Google Google’s 10 Things: Google Official Resume advice: Cover Letters examples: Hiring Process (official): 4Cs method from Workit daily: Google AI Principles: FAQ re-apply answered by recruiter on quora: How hiring decisions are made: How to prep the technical interview How to prep for the interview business Google Hiring Process steps quantified, advice Hiring at Google (technical HR): NY Times 2014 Interview with Laszlo Bock about what Google is looking for in new recruits:

Sunday, November 29, 2020

Happygirlzt: LeetCode入门(漫谈常见题型与解法)

 Here is the link. 

I will spend 30 minutes to watch the video Sunday morning. I will do that first thing in the morning. 


  • Two pointers (sliding window)
  • Binary search ( sorted, search space)
  • Combined with Map 
  • Prefix sum ( DP )
  • Quick select (kth ...)


   familiar with some monotonic stack questions

  • Maximum rectangle
  • Next greater elements
  • Trapping rain water - optimal, two pointers



Queue  BFS

Graphs   BFS, DFS, Dijkstra's


  • permutation - all possibilities
  • subsets
  • combination sum
  • partition equal
  • subset sum
  • N-Queen
  • Sudoku

Dynamic programming

  •  total ways
  • True/ False
  • max/ min

  • 0/1 Knapsack
  • perfect squares
  • Coin changes - total ways, minimum
  • climbing stairs 
  • decode ways
  • string related
    • regular expression matching
    • wildcard matching
    • Edit distance
    • LIS / LCS
  • 2D matrix
    • maximum square
    • range sum query
    • bomb enemy
    • unique paths, total ways
  • greedy  Heap (sort)  
    • Top K
    • Campus bikes
    • merge k sorted lists

Google onsite preparation - study material

 Nov. 27, 2020

Google | New Grad L3 [ Pending ]

Helpful Channels by Rank [According to me] :
Back To Back SWE ( Best one for everything )
Abdul Bari ( Very good, when it comes to learning new Data Structures )
WilliamFiset ( Very Good for learning Graph problems )
Kevin Naughton Jr. ( Good for random medium problems. Does not always solve the most effecient way, but it is good enough )
Nick White ( Same as the above )
happygirlzt ( Solves a lot of hard problems. Even if you don't understand her soll, if you watch her code you can figure out yourself )

I just could not believe that because of my age - 54 years old, I just could not believe that I need to refresh those graph algorithm again. I just make excuses for my laziness and so busy, I do not have time to spend learning from the above youtubers. 

I also start to record some videos. I learn that I should be more cheer up and enjoy my life. I have a full time job and have savings, without too much worry. I need to enjoy life and produce good and quality videos for my preparation as well. 

William Fiset: Breadth First Search grid shortest path | Graph Theory

Finding the shortest path on a grid using the Breadth First Search (BFS) algorithm on an unweighted graph. 

Here is the link. 

0:00 Previous Breadth first search video 0:44 Motivation for BFS on a grid 1:36 Converting your grid to an adjacency list/matrix 3:55 Grid vectors 6:09 Dungeon problem 7:51 Breadth first search on grid example 9:12 Using multiple queues for state representation 11:07 Pseudocode 15:56 Recap

William Fiset - Linkedin profile

 Here is the link. 

ACM-ICPC world finalist

honor dateMay 2017

honor descriptionWilliam competed in the ACM-ICPC world finals in May 2017 as part of the Canadian Mount Allison University team. The world finals competition is the equivalent of the Olympics for competitive programming.

Max Flow Ford Fulkerson | Network Flow | Graph Theory

 Here is the link. 

Max Flow Ford-Fulkerson 

0:00 Intro and motivation for maximum flow 2:42 Basics and definitions of network flow concepts 4:26 Augmenting paths, residual edges and the residual graph 8:05 Ford-Fulkerson with DFS example 9:49 Ford-Fulkerson time complexity 11:22 Faster network flow algorithms

Network Flows: Max-Flow Min-Cut Theorem (& Ford-Fulkerson Algorithm)

 Here is the link. 

I like to learn those algorithms quickly again. It is tough job for me to learn how to talk and think in the graph algorithm - Network flows, Max-flow min-cut theorem. 

Flow Networks: Ford–Fulkerson Algorithm: Max-Flow Min-Cut Theorem: Proofs: Reference "Algorithm Design" by Jon Kleinberg and Éva Tardos Chapters 7.1, 7.2 for excellent proofs on all of this.

Things I'd Improve On This Explanation (w/ More Time): 1.) I should have done a walk-through showing how the residual graph dictates how the original graph's edge flows (f(e)) are updated each iteration. (That would've made it more clear how the residual graph in the Ford-Fulkerson algorithm tells us how to update the flow on each edge (f(e)) in the original graph along the s-t path P, THEN we update the residual graph (also along P) to prepare for the next iteration.)

2.) Go into the actual augmentation once we find an s-t path P in the residual graph. We can only modulate the flow f(e) for each edge in the original graph on path P ± the smallest value residual graph edge on path P. The smallest forward edge on path P in the residual graph is the "bottleneck" to how much we can increase flow along the path P in the original graph. (hard to visualize...the textbook may have to take it away with this one, but when you understand this you'll really get it after watching this video)

I also didn't talk about time complexity, but the amount of while loop iterations is bounded to the capacity coming out of start node 's'. We can't ever push more flow from 's' than the sum of capacities of those exiting edges. If each interaction increases the value of the flow v(f) by 1 (and v(f) starts at 0 in the beginning since no "water" is going through the "pipes"), we can do at most C augmentations of the flow network where C = sum(edge capacities leaving 's').

In each while loop: - O(|V| + |E|) to find the augmenting path - O(|E|) to update the flows in the original graph - O(|E|) to update the residual graph

Dijkstra's Algorithm vs Prim's Algorithm

 Here is the link. 

 I like to go over algorithm video from back to back SWE quickly to prepare my Google onsite interview. It is tough job since I stop working on hackerrank contest for a long time, almost over 3 three years. I no longer work on complicated algorithm, and my practice is based on leetcode algorithm. I choose to work on easy and medium level algorithm. All those hard level algorithm, graph algorithm I no longer work on. 

Recently I came cross this dijkstra algorithm in Leetcode weekly contest, one is Google mock interview hard level algorithm - find minimum path in a matrix. 

Saturday, November 28, 2020

Cynthia Carroll - 30 years ago - HBA - my hashtag #googleOnsitePreparation

 Here is the video I watched. 

I chose to publish a video on this evening, and the first time I applied hashtag#googleOnsitePreparation. This is Google brought to me underneath this tag. 

Also I learn that how to make business decision under ambiguity. A very good teaching from professor of Harvard: Tsedal neeley, professor of business administration. 

Tracy song: Bravo! behavior interview sharing - a link

I asked Tracy song to share tips for my coming Google behavior interview. She shared me a link and are willing to offer me a mock interview as well. She told me so last year when we met in San Mateo city, my facebook MPK onsite trip. 

Here is the link. 

I am very good at learning things by reading. When I watch Google recruiter's video, my mind sometimes goes some other places. But reading is so important as writing. I will not miss any thing important. 

That is my style. I always like to write blogs compared to recording videos as well. Now I started to record youtube video to share as well. 

Googler - Blog - My favorite notes

Here is the link from Andriy  Buday.  

Here are original bullet points from me:

  • Do your job and do it well. Really well. Master the tools. Balance delivery and long-term perspective.
  • Never ever stop learning. Improve yourself in all areas. Soft and hard skills.
  • Work on projects that have impact and could grow to something big. If you don’t think you are on such a project change the project or change the project.
  • Find a mentor and work with your manager and others to get you where you want to be.
  • Look at what next level implies and do those things. Take responsibilities. Now.
  • Make your work visible and document what you’ve done.
  • Stay healthy. Sleep well.

Friday, November 27, 2020

Prepare for Your Google Interview: Leadership

 Here is the link. 

Googlers share targeted advice for the leadership aspects of Google's interview process. This video will cover tips for communication and leadership style, vision, overall best practices, and more! Skip ahead to: 0:35 - Communication and Leadership Style 1:25 - Working with Teams 2:08 - Vision 2:36 - Navigating Complexity and Ambiguity 3:07 - Delivering Results 4:01 - Best Practices Explore open jobs and internships at Google around the world → Learn about how Google interviews and hires → Subscribe to Life at Google for more videos →

Evaluate you project 

We'll be looking for: 

  • Define clear goals
  • Develop a plan
  • Delegate tasks
  • Manage progress
  • Maintain focus
Remain adaptable and offer space for creativity 

Explain thought process - how to solve the problems? 
Share with moments - Get it right 

We will be evaluating you on: 
  1. Communication and leadership style
  2. Navigating complexity and ambiguity
  3. Working with teams
  4. Vision 
  5. Delivering results
Authentic, knowledge, humble ...
Not most knowledge person in the room

Vision - change the world - make it better 
status quo - how we do things 

Tips From a TV Pro - Look and Sound Your Best On Zoom! | Dominique Sachse

 Here is the link. 

Sound like a pro - 

Keep the laptop close to you. 

Commands attention ......

Good light 

How To Look Good on Video Calls | Zoom FaceTime Skype | Blogger Secrets!

 Here is the link. 

Zoom Interview Tips | Strategies for Acing Online Interviews and Calls

 Here is the link. 

In this lesson, I give you my 2 amazing hacks to help you ace your online interview. If you're having the interview on Skype, Zoom, WebEx, Adobe Connect or some other online interview software, you'll be able to use my tricks here to help you ace your video call and get hired for the job you want! More and more, recruiters are reaching out first over video call so you want to be as comfortable as possible with online interviews. My steps are easy to use and a huge game-changer when it comes to online interview performance. You're going to want to be interviewed online after learning my strategies :)

How to Look Good on Video Calls - Skype, Zoom, FaceTime | Video Interviews

 Here is the link. 

Many of you are faced with the situation where you’ll have to run meetings remotely via video on different platforms, whether it be Skype, Zoom or some other today I wanted to share with you my best tips on how to look professional on camera while you have these video calls. If you've been asking "how to look good on video calls", "how to dress for video interviews", then this video is for you!

Put a few books underneath laptop if needed. Therefore the camera is at my eye level.

Lighting - in front of my face - luminate my face

Lighting is so important - sets the tone and how they feel about you

Shape up your face -

chest up - - business on top - normal wear in the office

neutral color - easy on eyes

think about background - Messy person - expose too much

Sound - microphone - echo - not clear

good quality video - listen to what you try to say

Google interview: 24 Most Asked Questions in Interviews at Google

 Here is the link. 

- Why Google Tell me about a situation where you had to solve a difficult problem Tell me about a team project you worked on We all deal with difficult customers from time to time. Tell me about a challenging client-facing situation and how you handled it. Describe a time when you improved a process with limited budget. Tell me about a time when you made sure a customer was pleased with your service. Tell me about a time you had to deal with ambiguity Describe a time when you found it difficult to work with someone from a different background. Tell me about a time when you came up with a new approach to a problem. “Tell me about a time when you missed an obvious solution to a problem Tell me about a time when you took the lead on a difficult project Tell me about a time you recovered from a difficult situation Give me an example of a time you faced a conflict while working on a team. How did you handle that? What's your greatest strength? And weakness? Tell me about the toughest decision you've had to make in the past six months Describe a long-term project that you managed. How did you keep everything moving along in a timely manner? Everyone starts somewhere. Talk about a time when you were new on the job and had a lot to learn. How did you manage that? an example when you had to push back to HQ or challenged a decision Tell me about a time when you worked with a difficult team member. Let’s say you need something important from a coworker and that person isn’t responding. How would you deal with this? a time when you faced a problem that had multiple possible solutions What did you do when you needed to motivate a group of individuals? Let’s say you’re working on a major project and you’re in the weeds. How do you find your way out? Tell me about a time when you were not able to meet a time commitment. What prevented you from meeting it? What was the outcome and what did you learn from it? Google’s 10 things:

Thursday, November 26, 2020

Interview skills: Prepare for your Google Interview: Tips and Example General Cognitive Ability Question

 Here is the link. 

GCA - congnitive ability

past vehavior - 

real life situation you may face

What is a GCA interview? 

Evaluation of your problem solving skills

Insight into ......

What is Google assessing? 

Understanding of the question

Preparation strategy

Ability to identify solutions

Justification for a specific solution 


4:55/ 11:02

Framework - how to build strong response? 

  • Take a moment before responding
  • Ask clarifying questions
  • Share logical assumptions
  • Show your work
  • Consider the pros and cons
  • Think about how you measure success
  • Tie it back to the role

EXPR stock: My research


I like to look into other retail clothing store stocks. I like to figure out how many Robinhood investors will speculate on those stocks, and I like to take chance to invest as well. 

  1. EXPR
  2. FRAN
  3. CAL
  4. DBI
  5. GCO
  6. CTRN
  7. CHS
  8. XELB
  9. PXL
Finviz - YTD peroformance 90% loss

Leetcode discuss: First practice - 1368. Minimum Cost to Make at Least One Valid Path in a Grid

 Here is the link. 

First practice - C# - BFS - Case study

Nov. 23, 2020
From the comment on the article about Google onsite interview, I decided to work on this hard level algorithm. I tried to think about how to solve it by myself, but I could not come out the details using BFS to solve it. I need to work on a small example, step by step, try to solve it by hand first.

Case study
grid = [[1,1,1,1],[2,2,2,2],[1,1,1,1],[2,2,2,2]]
Output: 3
How to solve the problem ?
Record minimum cost for each position in the matrix.

cost[0][0] = 0,
Apply BFS algorithm, start from (0,0), go right to (0, 1) or go down to (1, 0).
grid[0][0] = 1 which is to go right, so cost[0][1] = 0, no need to change the direction.
But cost[1][0] = 1 since direction should go down.
so the cost matrix
0, 0, ?, ?
1, ?, ? , ?
?, ?, ?, ?
?, ?, ?, ?
Next step is to put position (0, 1) and (1, 0) to the queue, and continue to apply BFS algorithm.
Check (0, 1), there are three directions, go left or right or down. Go right, no cost. Go left, cost 1, but cost(0,0) = 0, new path is bigger than 0. Ignore.
Cost matrix is the following:
0, 0, 0, ?
1, 1, ?, ?
?, ?, ?, ?
Skip rest of steps.

What if the above step to put neighbor nodes of (0,0) down first, right next, (1,0) and (0, 1).
(1, 0) has two directions to go, either go right or go down, so the cost of matrix is updated.
0, 0, ?, ?
1, 2, ?, ?
1, ?, ?, ?
?, ?, ?, ?
(0, 1) has two directions to go, eith go right or go down, so the cost of matrix (1, 1) is 1 < 2, so the minimum cost 1 should replace 2, which is the path from (0, 0) to go down and then go right.

I think that it is important to go over a simple test case step by step, so next time I can figure out how to solve the problem in onsite interview, like Google onsite.

Here are lessons I learn from this practice:

  1. BFS algorithm - the order of neighbor nodes into the queue should not matter in final result. Shortest cost path may not be found first, so it is important to update cost when a new path is found with minimum cost.
  2. It is a graph algorithm. The longer path may have smaller cost.

BFS solution
Declare cost[rows][] array to save minimum cost from (0,0) to (row, col). Apply BFS algorithm, and each step four directions are considered, and then cost will be calculated if the direction is different from the one given in grid[][].

The challenge idea is to find minimum cost to each node (row, col).

Deep thoughts
Nov. 24, 2020 10;35 PM

I asked the interviewee in my mock interview, and then I thought about more carefully. BFS algorithm will exhaust all possible paths, so that minimum cost will be calculated to reach (rows -1 , columns - 1).

If there are two loops, it should not work. The interviewee wrote the solution and I do believe that it will not exhaust all possible paths and each position will have minimum path from start position (0, 0).

The interviewee wrote the code like this:
while i < len(rows)
while j < len(cols)
i, j = calculate_i_j(grid[i][j])
if i > len ...

public class Solution {
    public int MinCost(int[][] grid)
        var rows = grid.Length; 
        var columns = grid[0].Length; 
	    var cost = new int[rows][];
        for(int row = 0; row < rows; row++)
            cost[row] = new int[columns];

	    for (int row = 0; row < rows; row++)
		    for (int col = 0; col < columns; col++)
			    cost[row][col] = int.MaxValue;
	    cost[0][0] = 0;

	    var queue = new Queue<int[]>();
	    queue.Enqueue(new int[]{0, 0});

        //                              right,    left,      down,      up 
        var directions = new int[,] { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 } };
        //  1 -> right, 2 <- left, 3 down, 4 up 
	    while (queue.Count > 0)
		    var node = queue.Dequeue();
            var row = node[0];
            var col = node[1];
		    int currentCost = cost[row][col];

		    for (int i = 0; i < directions.GetLength(0); i++)
			    var nextRow = row + directions[i, 0];
			    var nextCol = col + directions[i, 1];
                // grid[x][y] has 4 values 
                //  1 -> right, 2 <- left, 3 down, 4 up 
			    int newCost = currentCost + (grid[row][col] == (i + 1) ? 0 : 1); 

			    if (nextRow >= 0 && nextCol >= 0 && nextRow < rows && nextCol < columns)
                    // current path is shorter one
				    if (newCost < cost[nextRow][nextCol])
					    cost[nextRow][nextCol] = newCost;
					    queue.Enqueue(new int[]{nextRow, nextCol});

	    return cost[rows - 1][columns - 1];

Wednesday, November 25, 2020

Leetcode discuss: 1368. Minimum Cost to Make at Least One Valid Path in a Grid

 Here is the link. 

Nov. 25, 2020
I paid Leetcode premium, and I struggled to learn to solve all those 14 set Google mock onsite interview algorithms. Just after I finished those algorithms, I found this algorithm. It is the best one compared to all those 14 set algorithms. I did come cross this hard level algorithm from an aritcle on Leetcode about Google phone screen written by an anonymous player.

I got stuck in first 15 minutes thinking, since I still have weak muscle in algorithm analysis, and I like to push myself using this hard level one. I solved 560 algorithms, I could code any solution and make it really readable and perfect in logic, efficient.

7 benefits to master the algorithm
I spent over 8 eight hours to read and share three practices. I am still not the master of the algorithm.

My first practice is here. I took BFS approach and work on a case study to help myself think better.

Second practice is here. I made minor changes to apply BFS algorithm, instead of using Queue, I chose to use C# LinkedList - Double linked list, a deque structure to enforce the cost with value 1 to be find first if possible. All nodes in the queue have cost difference less and equal to one.

Third practice is here. I tried the idea to implement the solution using dynamic programming.

Here are highlights:

  1. Learn how to use BFS/ DFS, and also make minor modification from Queue to Deque;
  2. Understand how to modify a medium level problem to find minimum path to a hard level one. This one is to add direction and cost to change direction, and make this subproblems are hard to define using dynamic programming.
  3. This algorithm can help to solve a few other medium level algorithms, graph algorithms in general, minimum cost/ minimum distance/ greedy algorithm/ data structure.
  4. Be humble. Since I was nervous when I thought about how to solve it by myself. I did not solve it before I came cross two day ago. I need to learn how to work on a simple case first.
  5. I took distributed system and distributed algorithm, ad hoc network graduate course from 2002 to 2003 in Florida Atlantic University, but I did not write any code to help me understand the theorem. Now I practice a lot but I did not go back to learn and review more about theorems. Best way to learn is to practice a lot of algorithms first, and it will be easy to take any of those courses.
  6. Play a simple test case very well in practice, and it will really help reduce stress in the interviews as an interviewee. Graph algorithm is tough but usually it can be solved using DFS/ BFS or union find algorithm.
  7. As an interviewer, I can use the hard level algorithm to interview. Understand different stages of common mistakes, BFS/ DFS idea lacking, or other things.

I think that most important is to stay humble, continue to practice more hard level algorithm. Choose a hard level algorithm and really practice very well. Come back to review the algorithm very often as well.

Common mistakes - my mock interview as an interviewer
I can learn a lot to ask interviewees to solve the problem.
I asked the algorithm in mock interview as an interviewee, and the interviewee surprised me with bugs to write two while loop without thinking about BFS or DFS to cover all paths.

My first interviewee with buggy pseudo code.

def calculate_i_j(val):
    if val == 1:
        i = i
        j = j+1
    return i, j 

def modify_direction()
     return [possible_1 , possible_3]  # pair (i,j)

-- modification to find minimum cost 
calculate i, j from the current position's value
def find_Path()
    min_cost = 0 
    dp = 
    while i < len(rows) 
        while j < len(cols):
             cur_i, cur_j = calculate_i_j(grid[i][j])  // all directions -> 
             list_of_possible = modify_direction(i,j)
             for dir in list_of_possible:
                  i, j = dir
                  if i, j == cur_i, cur_j:
                      dp[i,j] = min(dp[i-1, j) , dp [i+1,j], dp[i,j+1], dp[i, j-1])
                      dp[i,j] = 1+min(dp[i-1, j) , dp [i+1,j], dp[i,j+1], dp[i, j-1])

-- old version has a bug
calculate i, j from the current position's value
def find_Path()
    min_cost = 0 
    while i < len(rows) 
        while j < len(cols):
             i, j = calculate_i_j(grid[i][j])
             if i >len(rows) or j > len(cols) or i< 0 or j <0: # crossing the boundaries

                  list_of_possible = modify_direction()
                  for dir in list_of_possible:
                       cost = 1+ find_Path(dir[0], dir[1])
                       min_cost = min(cost, min_cost)                     
    recursively_move(i, j)

Interviewee asked feedback and hints

  1. Missing dp[row, col], save every position minimum cost
  2. Exhaust all paths, use data structure, BFS, use Queue for example.

Improve analysis:
Work on a simple matrix 2 x 2.

all possible (0,0) -> (1, 1)
<- <- maximum cost -> rows + columns -> 0 -> binary search
-> ->

all paths -> miss a path -> all paths
snake - rows * columns - length ->cost 0 ->
paths -
complexity -
BFS / DFS - queue

(0,0) -> possible analysis - space, complexity

dp[i, j]  - minimum cost from (0,0) to (i, j)
exhaust all paths - (3, 3) - keep minimum cost - path - minimum 3 -> 5 <- 
current minimum cost -> 3    

<-  -> ->  ->1    
<-1 -> 2<-1 <-  <- 
->  -> ->  -> 
<-  <- <-  <- 

Go over (1, 1) position, from left, cost is 1, and from right cost is 2
<-  -> ->  ->1    
<-1 -> 2<-1 <-  <- 
->  -> ->  -> 
<-  <- <-  <- 

BFS - breadth first search