Tuesday, December 1, 2020

Leetcode discuss: 317. Shortest Distance from All Buildings

 Here is the link. 

First practice - C# - BFS - Queue - Case studies - Easy to follow

Nov. 30, 2020
It is a hard level algorithm. I chose to write the solution using BFS algorithm.

Case study
Sometimes there is no solution.

For example,
case 1:
1 , 1, 0
1, 0, 0
There is no way to access the building (0,0) position building. Return should be -1. So it is important to record how many buildings in total first, and then record how many buildings are accessible starting from the position with value 0. Compare two numbers, if any building is not accessible, return -1.

case 2:
How to set visited in the matrix, and make sure to avoid revisit the same position?
1 0 1
0 0 1
0 0 1

Space complexity should not be big concern. I prefer to use a copy of given matrix grid to pass into function to run BFS, and the value will be changed to mark visited.

Two concerns in my design, first is to do not count the same building more than once. The tip is to change the building value 1 to -1, so it can not be counted more than once.

Secondly it is ok to change value 0 to -1 as a way to mark visited land, same value as visited building. No worry about sharing the same value.

Let me walk through one search and see if it can be optimized.

Start from (0, 1) position since the value is 0, and then calculate the smallest distance to any building if it is accessible using BFS. BFS is very powerful tool to ensure the smallest distance is found first and it can be recorded properly.

Add integer array {0, 1, 0} to the queue, and then start BFS search; Dequeue {0, 1, 1}, the position in the matrix is (0,1), and the distance is 0. Check the position is building or not. If it is, then mark visit the building, add distance to total distance, return since it is not allowed to cross the building. If it is land, then add four possible neighbors into Queue, increment distance with value 1.

It is important to walk through the steps by hand, so it is easy to spot issues in the design.
Second step is to add four neighbors of (0, 1) to the queue, third step is to dequeue one by one those four positions.

Left neighbor is with value 1, one building is found, distance+=steps, and mark (0,0) with value -1.
Right neighbor is with value 1, another building is found, distance+=steps, and mark (0, 2) with value -1.
Down neighbor is with value 0, continue to search it's found neighbors.
Up neighbor is out-of-range.

Skip more details afterwards.
I do not think that it is needed to prune the algorithm if all buildings are found. Just let BFS search all possible paths and naturally end.

How to have a smoothly practice?
I have to work on my attention not to mix variables under stress, one tip is to reuse same variable, this way is to avoid mixing variables.

I wrote DFS first, and then I noticed that it did not work. It took me less than a few minutes to change them using Queue. But I do think that I have to pay more attention before I write the code. Think more carefully.

Additional checkings include the following:

  1. All buildings are found starting any position with 0 value in the given matrix;
  2. Distance is updated if one building is found;
  3. Make matrix a copy to pass as a function argument, easy to mark visit using -1, avoid duplicate count of same building;
  4. Avoid index-out-of-range error, do not declare valid checking variable after out-of-range check. Since only if it is in the range, then it is safe to check valid value; Put all checkings in one giant statement.
  5. I mixed row and col with x and y in my outOfRangeEtc, better to reuse row and col.
public class Solution {
    public int ShortestDistance(int[][] grid) {
            if(grid == null || grid.Length == 0 || grid[0].Length == 0)
                return 0; 
        
            var rows = grid.Length; 
            var columns = grid[0].Length; 
        
            var buildingCount = 0; 
            for(int row = 0; row < rows; row++)
            {
                for(int col = 0; col < columns; col++)
                {
                    if(grid[row][col] == 1)
                    {
                        buildingCount++; 
                    }
                }
            }
        
            // make sure buidling found == buildingCount
            // distance - BFS - minimum
            var minDistance = Int32.MaxValue; 
        
            for(int row = 0; row < rows; row++)
            {
                for(int col = 0; col < columns; col++)
                {
                    var current = grid[row][col];
                    if(current != 0)
                        continue; 
                
                    var found = 0;                 
                    var distance = 0; 
                
                    var gridCopy = new int[rows][];
                    for(int row1 = 0; row1 < rows; row1++)
                    {
                        gridCopy[row1] = new int[columns];
                    }
                
                    for(int row1 = 0; row1 < rows; row1++)
                    {
                        for(int col1 = 0; col1 < columns; col1++)
                        {
                            gridCopy[row1][col1] = grid[row1][col1];
                        }
                    }
                
                    runBFS(gridCopy, row, col, ref found, ref distance);
                
                    if(found == buildingCount)
                    {
                        minDistance = Math.Min(minDistance, distance);
                    }
                }
            }
        
            return minDistance == Int32.MaxValue? -1: minDistance; 
        }
    
        private void runBFS(int[][] grid, int row, int col, ref int found, ref int distance)
        {
            var rows    = grid.Length; 
            var columns = grid[0].Length; 
        
            var queue = new Queue<int[]>(); 
            queue.Enqueue(new int[]{row, col, 0});

            while (queue.Count > 0)
            {
                var count = queue.Count;

                for (int i = 0; i < count; i++)
                {
                    var node = queue.Dequeue();

                    var x = node[0];
                    var y = node[1];
                    var steps = node[2];

                    var outOfRangeEtc = x < 0 || x >= rows || y < 0 || y >= columns ||
                     grid[x][y] == 2 || grid[x][y] == -1;
                    if (outOfRangeEtc)
                    {
                        continue;
                    }

                    if (grid[x][y] == 1)
                    {
                        grid[x][y] = -1;
                        distance += steps;
                        found++; 
                    }
                    else
                    {   // mark visit
                        grid[x][y] = -1;

                        queue.Enqueue(new int[] { x, y - 1, steps + 1 });
                        queue.Enqueue(new int[] { x, y + 1, steps + 1 });
                        queue.Enqueue(new int[] { x - 1, y, steps + 1 });
                        queue.Enqueue(new int[] { x + 1, y, steps + 1 });
                    }
                }
            } 
        }
}


14 set Google mock onsite interviews - Leetcode

 Dec. 1, 2020

Introduction

It is the first time I learn the value of $150 US dollars value. I paid subscription, and then I took the time to complete 14 set of Google mock onsite interviews. I failed and learned so many algorithms in less than one month. 

14 set Google mock onsite


What do I learn most from Google onsite preparation?

 Dec. 1, 2020

Introduction

I am thinking about what I learn most from Google onsite interview preparation. I just could not believe that I want to get an offer after three Amazon onsites, two facebook onsite, my first Google onsite. Time is up, and I just cannot finish another 14 set Facebook mock onsite interviews, over 10 Microsoft mock interviews, and 10 Amazon mock onsite interviews. 

What do I learn most from Google onsite preparation?

I just could not believe that I spent first five months to learn how to invest. I like to show my Leetcode submission history. 


I will figure out in last week preparation. It is my favorite project to work on. 

How to Lead 60,000 Employees | Laszlo Bock, Google's Former People Chief

 Here is the link. 

Laszlo Bock is a Senior Advisor at Google and the author of "Work Rules!" During his tenure at Google, he led Google's people function, and was responsible for attracting, developing, retaining, and delighting "Googlers." Under his leadership, Google was named the Best Company to Work For more than 30 times around the world, and received over 100 awards as an employer of choice. In 2010, Bock was named "Human Resources Executive of the Year" by HR Executive Magazine. At a special IVY Ideas Night in 2015, Bock shared insights from his new book and talked about the essentials of good leadership. IVY is the world's first Social University. To learn more, please visit www.ivy.com.


Transparency

collaborate, not driven by the fear

take the person out-of-job - open things up



Monday, November 30, 2020

Google's 10 design principles via Laszlo Bock

 Here is the link. 

  1. Focus on people
  2. Every millisecond counts
  3. Simplicity is powerful
  4. Engage beginners and attract experts
  5. Dare to innovate

Google interview preparation: Ten things we know to be true

 Here is the article. 


My notes from the following 10 things: 

  1. Placement in search is not distracting - talk about my experience with sales manager
  2. Search problems - focus on exclusively on solving search problem
  3. Web browser, search results - fraction of a second

We first wrote these “10 things” when Google was just a few years old. From time to time we revisit this list to see if it still holds true. We hope it does—and you can hold us to that.

1. Focus on the user and all else will follow.

Since the beginning, we’ve focused on providing the best user experience possible. Whether we’re designing a new Internet browser or a new tweak to the look of the homepage, we take great care to ensure that they will ultimately serve you, rather than our own internal goal or bottom line. Our homepage interface is clear and simple, and pages load instantly. Placement in search results is never sold to anyone, and advertising is not only clearly marked as such, it offers relevant content and is not distracting. And when we build new tools and applications, we believe they should work so well you don’t have to consider how they might have been designed differently.

2. It’s best to do one thing really, really well.

We do search. With one of the world’s largest research groups focused exclusively on solving search problems, we know what we do well, and how we could do it better. Through continued iteration on difficult problems, we’ve been able to solve complex issues and provide continuous improvements to a service that already makes finding information a fast and seamless experience for millions of people. Our dedication to improving search helps us apply what we’ve learned to new products, like Gmail and Google Maps. Our hope is to bring the power of search to previously unexplored areas, and to help people access and use even more of the ever-expanding information in their lives.

3. Fast is better than slow.

We know your time is valuable, so when you’re seeking an answer on the web you want it right away–and we aim to please. We may be the only people in the world who can say our goal is to have people leave our website as quickly as possible. By shaving excess bits and bytes from our pages and increasing the efficiency of our serving environment, we’ve broken our own speed records many times over, so that the average response time on a search result is a fraction of a second. We keep speed in mind with each new product we release, whether it’s a mobile application or Google Chrome, a browser designed to be fast enough for the modern web. And we continue to work on making it all go even faster.

4. Democracy on the web works.

Google search works because it relies on the millions of individuals posting links on websites to help determine which other sites offer content of value. We assess the importance of every web page using more than 200 signals and a variety of techniques, including our patented PageRank™ algorithm, which analyzes which sites have been “voted” to be the best sources of information by other pages across the web. As the web gets bigger, this approach actually improves, as each new site is another point of information and another vote to be counted. In the same vein, we are active in open source software development, where innovation takes place through the collective effort of many programmers.

5. You don’t need to be at your desk to need an answer.

The world is increasingly mobile: people want access to information wherever they are, whenever they need it. We’re pioneering new technologies and offering new solutions for mobile services that help people all over the globe to do any number of tasks on their phone, from checking email and calendar events to watching videos, not to mention the several different ways to access Google search on a phone. In addition, we’re hoping to fuel greater innovation for mobile users everywhere with Android, a free, open source mobile platform. Android brings the openness that shaped the Internet to the mobile world. Not only does Android benefit consumers, who have more choice and innovative new mobile experiences, but it opens up revenue opportunities for carriers, manufacturers and developers.

6. You can make money without doing evil.

Google is a business. The revenue we generate is derived from offering search technology to companies and from the sale of advertising displayed on our site and on other sites across the web. Hundreds of thousands of advertisers worldwide use AdWords to promote their products; hundreds of thousands of publishers take advantage of our AdSense program to deliver ads relevant to their site content. To ensure that we’re ultimately serving all our users (whether they are advertisers or not), we have a set of guiding principles for our advertising programs and practices:

  • We don’t allow ads to be displayed on our results pages unless they are relevant where they are shown. And we firmly believe that ads can provide useful information if, and only if, they are relevant to what you wish to find–so it’s possible that certain searches won’t lead to any ads at all.

  • We believe that advertising can be effective without being flashy. We don’t accept pop–up advertising, which interferes with your ability to see the content you’ve requested. We’ve found that text ads that are relevant to the person reading them draw much higher clickthrough rates than ads appearing randomly. Any advertiser, whether small or large, can take advantage of this highly targeted medium.

  • Advertising on Google is always clearly identified as a “Sponsored Link,” so it does not compromise the integrity of our search results. We never manipulate rankings to put our partners higher in our search results and no one can buy better PageRank. Our users trust our objectivity and no short-term gain could ever justify breaching that trust.

7. There’s always more information out there.

Once we’d indexed more of the HTML pages on the Internet than any other search service, our engineers turned their attention to information that was not as readily accessible. Sometimes it was just a matter of integrating new databases into search, such as adding a phone number and address lookup and a business directory. Other efforts required a bit more creativity, like adding the ability to search news archives, patents, academic journals, billions of images and millions of books. And our researchers continue looking into ways to bring all the world’s information to people seeking answers.

8. The need for information crosses all borders.

Our company was founded in California, but our mission is to facilitate access to information for the entire world, and in every language. To that end, we have offices in more than 60 countries, maintain more than 180 Internet domains, and serve more than half of our results to people living outside the United States. We offer Google’s search interface in more than 130 languages, offer people the ability to restrict results to content written in their own language, and aim to provide the rest of our applications and products in as many languages and accessible formats as possible. Using our translation tools, people can discover content written on the other side of the world in languages they don’t speak. With these tools and the help of volunteer translators, we have been able to greatly improve both the variety and quality of services we can offer in even the most far–flung corners of the globe.

9. You can be serious without a suit.

Our founders built Google around the idea that work should be challenging, and the challenge should be fun. We believe that great, creative things are more likely to happen with the right company culture–and that doesn’t just mean lava lamps and rubber balls. There is an emphasis on team achievements and pride in individual accomplishments that contribute to our overall success. We put great stock in our employees–energetic, passionate people from diverse backgrounds with creative approaches to work, play and life. Our atmosphere may be casual, but as new ideas emerge in a café line, at a team meeting or at the gym, they are traded, tested and put into practice with dizzying speed–and they may be the launch pad for a new project destined for worldwide use.

10. Great just isn’t good enough.

We see being great at something as a starting point, not an endpoint. We set ourselves goals we know we can’t reach yet, because we know that by stretching to meet them we can get further than we expected. Through innovation and iteration, we aim to take things that work well and improve upon them in unexpected ways. For example, when one of our engineers saw that search worked well for properly spelled words, he wondered about how it handled typos. That led him to create an intuitive and more helpful spell checker.

Even if you don’t know exactly what you’re looking for, finding an answer on the web is our problem, not yours. We try to anticipate needs not yet articulated by our global audience, and meet them with products and services that set new standards. When we launched Gmail, it had more storage space than any email service available. In retrospect offering that seems obvious–but that’s because now we have new standards for email storage. Those are the kinds of changes we seek to make, and we’re always looking for new places where we can make a difference. Ultimately, our constant dissatisfaction with the way things are becomes the driving force behind everything we do.


How Google Thinks About Hiring, Management and Culture

 Here is the link. 

Assess people - training interviewer 

15 minutes - same quality results - train people thinner and thinner

Reason:

confidence, conscientious, 

Snap judgement - look for data - Separate committee - maintain the quality 

Hiring committee - maintain the quality 

Objective, structure interviews - do not predict performance 

screen hard level - drill down - do not make decision on one person's opinion

Build a website - 2013 - start to work on website - 

Get work done - set goal - manager - we want to make sure that people get work done 

Manage them very well - Forget everything you know - Behavior 

Employee - peer feedback - manager - take away power away from managers 

People can see them customers and feedbacks 

500 engineers - report to one director 

Training people - story in the book - tell them the story how to play golf like Tiger Woods 

HR - consultant - Share group entrepreneurs 

Manage - day one - 50,000 people - how to manage them? 

close the deal and make things happen

Partner, KPCB - beth 

Compensation - pay unfairly 

politics, performance above average - average MBA - system is not fair - performance is observable

different research - software engineers - best people are way better than average 

Difference too big - salary - 20% to 30% 

Best people are way more than that - not 10 times more - absolute - exponential

justify - pay transparent - problems - no one is happy 

procedure justified - change the outcome - appreciated - second thing 

79 cents a dollar - 

Based on your job - not prior pay 

Do not create new one - really wide distributed - market will pay them very well 

Influence - get them in the market - absolute best people and generate most value 


New york times events: Becoming a Googler...and Other Opportunities

 Here is the link. 

Laszlo Bock, senior vice president, people operations at Google, talks about what the world's largest companies look for in an employee, in conversation with Thomas L. Friedman.

I am taking notes while I watch the video:

  • Intellectual learning ability
  • Step in when there is a problem
  • Diversify background
  • Step back
  • Culture fit
  • People just like us - comfortable ambiguity
  • Highly conscientious
  • Not my problem - this is not good
  • Expertise - quite a good engineer
  • Being able to learn, figure out how to do it - 5% or 10% come out something new
  • Nail, hammer - smart creativity
  • 14% no college degree - how they acquire the skills - online training - school - pick up all over the places - skillset - screen candidates - guilty - hiring more people - net hiring 5,000 - 8,000 - 2 million people
  • MIT students - apply everyday - how to manage them?
  • Human being - read the resume - overinvest the recruiters
  • Assess candidates - phone screen - technical coding abilities - cognitive ability
  • GPA - used to require every one - transcript - a candidate - Look good, send me the transcript - people lie - 1% - 4.0 but 2.8, round up, no one rounds down
  • Internal - 360 -> 28 performance factors - how to promote? - citizenship - act like community - 300 independent variables - grades are predicted performance first two years out-of-school
  • Train recruiters, people, curve of college
  • Big mistakes in writing a job resume - trick - interview - two valuable skills in the life
  • To answer the question, led the team and grew the sales, complete x by doing y with number c, using percentage
  • What mistakes - wear a suit - Do not do that - not in Google
  • vulnerable position - show best you can - curious - how this place works - demonstrate authentic interest
  • Something you like, or something you hate
  • Distinguish - authentic - not too many people to do that - authentic
  • Develop resilience - compound interest, credit card interest
  • Google minority hiring - African American -
  • College choice - what is your advice? 18 yrs old,
  • Signals - company recognized, fancy school, widely known, everybody else - send signal sending out
  • Related signals - anything, skillset you get from that, transfer to anything - fundamental
  • Cost/ benefits - quantitative classes
Questions and answers:

1. Employer more good at assessment the people - definition, all are average
2. Push them to take hard level class - quantitative classes; Fund AP classes - enrollment of the classes, affluent and white
3. Talent acquisition - diversity, granddaughter gets a good job - two coolest things -
Build relationship - conscientious - bias - offices all over the world
Most talent people likes to go to USA - non US citizen - quantitative field
Ageism - discrimination - span - 83 year old
Bonus pool - not evidence - unfriendly - uncomfortable - continue to look into closely

30 minutes, well-done! End at 10:36 PM.

Hired&CO: Google Interview and Hiring Process | Questions and Answers

 Here is the link. 


12:49

Google - great communication 

All those people are brilliant communicators. 

Top-notch communication as an interviewer. 

13:44 

General cognitive ability test - 

Think out loud 

- Talk this out loud

- Not having a right answer - how you think about it?

- Think resourcefully, and think quickly. 

- Quick is important! 

16:41

Structure interviews - behavior questions and situational

They ask a question -> They go deep -> 

Fail -> how does that impact the team? -> how do you do? Third follows up, be able to respond. 

4. Conscientious and Googleness 

Use we, not I - give credits to people - use I all the time. 

Ego-central 

More humble - people being people - Google is more relax culture - more low key, more authentic 

Act like owners, rather than employees. 


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: https://www.themuse.com/advice/30-beh... Data structure hiring at Google https://youtu.be/les1Rit15_0 Google’s 10 Things: https://www.google.com/about/philosop... Google Official Resume advice: https://www.youtube.com/watch?v=zrXZB... Cover Letters examples: http://www.vault.com/blog/resumes-cov... Hiring Process (official): https://careers.google.com/how-we-hire/ 4Cs method from Workit daily: https://youtu.be/Y95eI-ek_E8 Google AI Principles: https://www.blog.google/technology/ai... FAQ re-apply answered by recruiter on quora: https://www.quora.com/How-soon-can-yo... How hiring decisions are made: https://www.cnbc.com/amp/2018/01/10/g... How to prep the technical interview https://youtu.be/ko-KkSmp-Lk How to prep for the interview business https://youtu.be/_zIlQ-YfvdE Google Hiring Process steps quantified, advice https://youtu.be/CBszg2gFcHs Hiring at Google (technical HR): https://youtu.be/ZoYZft2gZ5Q NY Times 2014 Interview with Laszlo Bock about what Google is looking for in new recruits: https://www.youtube.com/watch?v=5jeCJ...

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. 


Arrays

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

Stacks

   familiar with some monotonic stack questions

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

   

   Next 

Queue  BFS

Graphs   BFS, DFS, Dijkstra's

Backtracking 

  • 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: https://en.wikipedia.org/wiki/Flow_ne... Ford–Fulkerson Algorithm: https://en.wikipedia.org/wiki/Ford%E2... Max-Flow Min-Cut Theorem: https://en.wikipedia.org/wiki/Max-flo... 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 youtube.com this evening, and the first time I applied hashtag#googleOnsitePreparation. This is Google youtube.com 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.