Friday, June 5, 2020

Leetcode discuss: 215. Kth Largest Element in an Array

Here is the post.

C# SortedDictionary minimum heap practice in 2020

June 4, 2020
Find kth largest element is very classical algorithm. I work on two tricky things to convert the problem into a minimum heap problem.
Warmup and best design talk
Let us walk through an example, how to design data structure heap for the help.
For example, integer array [1, 2, 3, 4, 5,6,7,8,9,10], k = 2
Minimum heap
Every number has to be went through, so the last one the heap should be [9, 10], the size is 2.
9 is the top of minimum heap.
Another example, still [1, 9, 2, 3, 4, 5, 6, 7, 8, 10], the last one the heap still should be [9, 10], the size is 2. Kth number is the top of heap.
The size of heap is important to find kth number in minimum heap. k = 2, heap size is 2.
If the array size is 10,000, number from 1 to 10,000, and then kth number is 9995, why we keep heap size as 9995, it is better to reverse the array in ascending order using -10,000 to -1. So the heap size can be 5 instead of 9995.
The exercise is warmup our design muscle and have a short break ice for real coding work.
Maximum heap
Since maximum heap can be processed using negative value of element array. We can stay with the minimum heap all the time.
Two tips
Work on a test case, array, [1, 2, 3, 4, 5], kth largest element, for example, 2th largest element is the fourth smallest element. Both are 4.
In order to apply kth largest element problem, it is to save -1 * element value. So largest one is converted into smallest one.If k is very big number close to size of array, then -1 * element will make sense, because n - k + 1 will be small integer, the minimum heap's size is small one.
Here are my highlights:
  1. Design a minimum heap using SortedDictionary<int, int>, key is -1 * element value, value is count of element value; Notice that largest kth element not largest kth distinct element;
  2. Write a class called MinHeap, two APIs, one is called Add(int val), second one is PopMin(), public property called sorted using SortedDictionary<int, int>;
  3. Work on test case [1, 2, 3, 4,5], k = 2, 2th largest one is 4, and it is 4th smallest one. k -> n - k + 1 is the conversion mapping;
  4. In order to get kth smallest minimum element, the heap size should be n - k + 1 at most.
Tips to share
I wrote a solution using minimum heap to find 814: third largest distinct element in the array, similar idea. The post is here.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _215_kth_largest_element
{
    class Program
    {
        static void Main(string[] args)
        {
        }

        /// <summary>
        /// First practice: June 4, 2020
        /// </summary>
        public class MinHeap
        {
            /// <summary>
            /// use SortedDictionary to implement the minimum heap              
            /// </summary>
            public SortedDictionary<int, int> sorted = new SortedDictionary<int, int>();

            public void Add(int val)
            {
                if (sorted.ContainsKey(val))
                {
                    sorted[val]++;
                }
                else
                {
                    sorted.Add(val, 1); 
                }
            }

            /// <summary>
            /// SortedDictionary<int> default is in ascending order. 
            /// 
            /// </summary>
            /// <returns></returns>
            public int PopMin()
            {
                int minKey = sorted.Keys.First();

                var count = sorted[minKey];
                if (count == 1)
                {
                    sorted.Remove(minKey);
                }
                else
                {
                    sorted[minKey]--;
                }

                return minKey;
            }
        }

        /// <summary>
        /// Find kth largest element in the array, not kth largest distinct element
        /// Save each element value * -1, so kth largest one will be (n - k + 1)th smallest one. 
        /// </summary>
        /// <param name="nums"></param>
        /// <param name="k"></param>
        /// <returns></returns>
        public int FindKthLargest(int[] nums, int k)
        {            
            if (nums == null || nums.Length == 0 || k < 0)
                return -1;

            k = nums.Length - k + 1; // convert largest kth to smallest 

            var length = nums.Length;
            var heap = new MinHeap();            
          
            // Let us keep min heap size as k all the time
            // In other words, add one number to the heap, 
            // move the minimum one in the heap as well if heap's size is bigger than k. 
            int size = 0; 
            
            for (int i = 0; i < length; i++)
            {
                var negativeValue = -1 * nums[i];
                size++; 

                heap.Add(negativeValue);

                if (size > k)
                {
                    heap.PopMin();
                }
            }

            return -1 * heap.PopMin();
        }
    }
}


Leetcode discuss: 215. Kth Largest Element in an Array

June 5, 2020

Here is the post.

C# SortedDictionary minimum heap practice II in June 2020

It is my second practice on this algorithm. I found out that my first practice has a unnecessary work to save -1 * element value in the array to minimujm heap. Here is the first practice. I think that my first practice shows weakness of my analytical skills using minimum heap; I should argue that minimum heap can deal with kth largest element algorithm perfectly, without using maximum heap.
Case study
Given an array, find kth largest element in the array. For example, array [1, 2, 3, 4, 5], k = 2, so kth largest element is value 4, index position = 3; We have to iterate all numbers in the array in order to find kth largest one.
If minimum heap is kept to size k, then kth largest one will be on top of minimum heap after last element is visited.
Kth largest element in the array can be solved using minimum heap, and heap size is also k. If k is not too largest, heap size is not an issue, then I just choose to go ahead to save element value in minimum heap; otherwise I can play the trick to save -1 * element value to reduce heap size.
Here are higlights:
  1. Design a minimum heap and understand the importance to keep minimum heap size as k;
  2. Use C# SortedDictionary<int, int> strong typing, value data type is count of same element value in the array;
  3. Look into other C# data structure which may be best choice compared to SortedDictionary<int, int>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _215_kth_largest_element
{
    class Program
    {
        static void Main(string[] args)
        {
        }

        /// <summary>
        /// First practice: June 4, 2020
        /// </summary>
        public class MinHeap
        {
            /// <summary>
            /// use SortedDictionary to implement the minimum heap              
            /// </summary>
            public SortedDictionary<int, int> sorted = new SortedDictionary<int, int>();

            public void Add(int val)
            {
                if (sorted.ContainsKey(val))
                {
                    sorted[val]++;
                }
                else
                {
                    sorted.Add(val, 1);
                }
            }

            /// <summary>
            /// SortedDictionary<int> default is in ascending order. 
            /// 
            /// </summary>
            /// <returns></returns>
            public int PopMin()
            {
                int minKey = sorted.Keys.First();

                var count = sorted[minKey];
                if (count == 1)
                {
                    sorted.Remove(minKey);
                }
                else
                {
                    sorted[minKey]--;
                }

                return minKey;
            }
        }

        /// <summary>
        /// Find kth largest element in the array, not kth largest distinct element
        /// For example, [1, 2, 3, 4, 5], kth largest element is 4 if k = 2; how to find 4? 
        /// All elements should be searched, last one is 5, kth one should be minimum one on the top. 
        /// The tricky part is to keep minimum heap size as k
        /// </summary>
        /// <param name="nums"></param>
        /// <param name="k"></param>
        /// <returns></returns>
        public int FindKthLargest(int[] nums, int k)
        {
            if (nums == null || nums.Length == 0 || k < 0)
                return -1;            

            var length = nums.Length;
            var heap = new MinHeap();

            // Let us keep min heap size as k all the time
            // In other words, add one number to the heap, 
            // move the minimum one in the heap as well if heap's size is bigger than k. 
            int size = 0;

            for (int i = 0; i < length; i++)
            {
                var value = nums[i];
                size++;

                heap.Add(value);

                if (size > k)
                {
                    heap.PopMin();
                }
            }

            return heap.PopMin();
        }
    }
}
treesminimum heapc# sorteddictionary

Thursday, June 4, 2020

OVV.TO stock: Institution buyer and stock went up 200% from March 27, 2020

June 4, 2020

Introduction


It is so shameful for me as an investor. I do not purchase more share of OVV.TO after March 27, 2020, and I just watch the market price went up 200%. Today I shared stock using my blog by search OVV.TO, and I have 30 minutes to look up what are those institution buyers recently.

Buyers 

Here is the link.

Major holders that have opened new positions in OVV / Ovintiv Inc. include Dodge & Cox, DODFX - Dodge & Cox International Stock Fund, Price T Rowe Associates Inc /md/, FIL Ltd, Letko, Brosseau & Associates Inc, Davis Selected Advisers, DODWX - Dodge & Cox Global Stock Fund, FMR LLC / Fidelity, VGTSX - Vanguard Total International Stock Index Fund Investor Shares, ACSTX - Invesco Comstock Fund Class A, Millennium Management Llc, Causeway Capital Management Llc, Phoenix Holdings Ltd., NYVTX - Davis New York Venture Fund Class A, Two Sigma Advisers, Lp, Two Sigma Investments Llc, Monaco Asset Management SAM, Wellington Management Group LLP, VGENX - Vanguard Energy Fund Investor Shares, and Nomura Holdings Inc.

Major holders - my sorting 

Dodge & Cox, 
DODFX - Dodge & Cox International Stock Fund, 
Price T Rowe Associates Inc /md/, 
FIL Ltd, 
Letko, Brosseau & Associates Inc, 
Davis Selected Advisers, 
DODWX - Dodge & Cox Global Stock Fund, 
FMR LLC / Fidelity, 
VGTSX - Vanguard Total International Stock Index Fund Investor Shares, 
ACSTX - Invesco Comstock Fund Class A, 
Millennium Management Llc, 
Causeway Capital Management Llc, 
Phoenix Holdings Ltd., 
NYVTX - Davis New York Venture Fund Class A, 
Two Sigma Advisers, 
Lp, 
Two Sigma Investments Llc, 
Monaco Asset Management SAM, 
Wellington Management Group LLP, 
VGENX - Vanguard Energy Fund Investor Shares, 
and Nomura Holdings Inc.

2020-05-28 DODFX - Dodge & Cox International Stock Fund   28,485.424 shares
2020-05-26 Morgan Stanley 1,380,733 shares
2020-05-15 Royal Bank of Canada  458,381 shares
2020-05-15 Vanguard Group Inc  1,236,631
2020-05-15 Goldman Sachs Group Inc 1,973,960
2020-05-15 Price T Rowe Associations Inc  14,437,180
2020-05-14 Dodge & Cox 38,017,797
2020-05-12 JP Morgan Chase & Co 755,658




 



Spirit singled out at Barclays as a top airline stock

Here is the article.

The uncomplicated story at Spirit Airlines (SAVE +8.2%) draws in Barclays.
"With the absolute lowest cost structure and lowest airfares of US airlines, we believe Spirit will likely be one of the first carriers to achieve financial recovery," predicts the firm.
"While the future for travel demand in a post-pandemic period remains one of the largest questions for investors and airline management teams alike, most would agree that leisure demand is likely to recover first. Spirit's network is almost entirely exposed to either leisure or travel demand associated with visiting friends and relatives."
Actionable Items
I like to think about investing on Spirit airline in short term or mid-term. 





Wednesday, June 3, 2020

Buying Spirit Airlines Stock Right Now Is a Risky Gamble. Here's How It Could Pay Off

Here is the article.

Here are facts mixed with arguments:


  1. The number of travelers heading through U.S. airport security checkpoints on May 31 was down 86% year over year, and that is an improvement over the 95%-plus drop recorded in mid-April
  2. Industry stalwarts like Southwest Airlines
  3. Smaller, second-tier carriers like Spirit Airlines (NYSE:SAVE)
  4. Buffett gave up on industry stalwarts like Southwest Airlines
  5. The most attractive in the industry over the next 12 to 18 months is SAVE, if survive
  6. Spirit airline - $915 million in cash as of April 30
  7. As of early May Spirit was burning through about $4 million per day, but that figure has hopefully come down some in recent weeks as demand appears to be slowly rebounding off an April bottom.
  8. burning $4 million per day - Spirit airline 
  9. The airline has applied for U.S. Treasury loans under the CARES Act for up to $741 million, with airlines allowed to wait until Sept. 30 to decide if they want to take all or part of what is available to them.
  10. Spirit has $650 million in unencumbered tangible assets, including 29 aircraft.
  11. In 2019, Spirit spent 7.97 cents per available seat mile, an industry metric used as a base unit for airline flying.
  12. Discount king Southwest, by comparison, spent 11.74 cents per available seat mile last year.

DAL stock: Domestic airlines surge as Trump looks to ban Chinese carriers

DAL stock: Domestic airlines surge as Trump looks to ban Chinese carriers
Here is the link.

3:06 - 3:40 30 3 minutes talk from Karen

Karen recommended LUV - south west airline, domestic airline only.

check us balance sheet - 5% up on June 3, 2020, Delta airline downgrade recently - Google it!

4:02 - 4:10 
United airlines 33.65  +12.50%
Delta Air lines 28.47  +7.08%
American Airlines 11.85 +5.61%
Spirit Airlines 17.31 +19.46%
Southwest Air 36.42  +5.63%

My research 

From May 14, 2020 to June 3, 2020, 58% increase

Here is my record using Yahoo finance -> My portfolio:

LUV stock: Domestic airlines surge as Trump looks to ban Chinese carriers

LUV stock: Domestic airlines surge as Trump looks to ban Chinese carriers

Here is the link.

3:06 - 3:40 30 3 minutes talk from Karen

Karen recommended LUV - south west airline, domestic airline only.

check us balance sheet - 5% up on June 3, 2020, Delta airline downgrade recently - Google it!

From May 14, 2020 to June 3, 2020, 58% increase

4:02 - 4:10 
United airlines 33.65  +12.50%
Delta Air lines 28.47  +7.08%
American Airlines 11.85 +5.61%
Spirit Airlines 17.31 +19.46%
Southwest Air 36.42  +5.63%

My research

Here is my record using Yahoo finance -> My portfolio:




Business plan: Ford stock

June 3, 2020

Introduction


It is difficult for me to manage $11,000 dollars cash in my Key largo portfolio with Ameritrade.com. I like to work on a short term project to purchase Ford Stock. I like to work on the design, exit strategy, risk management and other detail.

Ford stock


I purchased Ford stock in March, 2020. Last week Ford stock went up more than 20%. It is time for me to investment $3000 dollars or $4000 dollars in short term, I like to see if I can make 10% profit.

Here is my purchase of Ford stock. The report is generated by Yahoo Finance -> My portfolio.


GE stock research - CFRA - May 30, 2020 review

June 2, 2020

Introduction


I just came cross GE stock review less than two days on Ameritrade.com. I like to spend time to learn GE business, and see how distressed business can turn into profit after coronavirus issues settle down. I like to go over CFRA stock review, and see how the report is structured.

CFRA - GE stock review

high - Analyst's risk assessment

Primary risks facing GE are cyclical demand and high
leverage, in our view. We estimate approximately 70% of
the company's revenue is generated from aviation and
energy markets that can suffer severe downturns during
recessions. The largest segment, Aviation (34% of
revenue), has particularly high risk due to the
unprecedented distress for jet engine customers during
the Covid-19 crisis, in our opinion. GE also has high
leverage, with operating earnings covering interest by an
estimated 2x in 2019, well below peer average of around
15x. The high debt burden reduces GE's flexibility to
weather downturns, in our view.

Highlights

Revenue fell 7% in Q1, with mixed performance
across segments. Renewable Energy (16% of
revenue, +26% YoY) saw a surge in sales, led by
onshore wind products benefiting from tax
incentives, in our view. This strong performance
was offset by large declines in Power (20%,
-13%) and Aviation (34%, -13%). We think
Aviation’s decline was driven by exposure to
Boeing, as GE is the engine maker for the
grounded 737 MAX. But even with MAX
production expected to resume by H2 2020, we
think Aviation revenues will move even lower
through 2021, as demand for commercial air
travel is lowered near term by Covid-19, and
lowered longer term by high unemployment, in
our view.
Power and Renewable are likely to see
downturns this year as well, although more
modest, in our view, as their power utility
clients will likely be more resilient during the
recession due to the essential nature of
electricity. We expect 2020 EPS of -$0.13, as
GE will struggle to absorb large fixed costs
associated with plants during the recession, in
our view.
In March 2020, GE sold its Healthcare
BioPharma business to Danaher for $21B.
BioPharma generated $1.3B in FCF in 2019,
which was more than half of GE’s total FCF of
$2.3B

Investment rationale/ risk

Our Hold reflects high uncertainty related to
GE's deleveraging plan brought about by the
Covid-19 crisis. Aviation and Healthcare were
GE's FCF engines in 2019, generating $4.4B
and $2.5B, respectively; against total FCF of
just $2.3B, as Power and Renewable burned
cash in 2019 despite a healthy economy. In
2020, we see virus-induced distress in
commercial air travel pushing Aviation into the
red, while Healthcare, normally a stalwart
during recessions, will see FCF more than
halved after the BioPharma sale. In our view,
the combined result could be much of the
BioPharma sales proceeds GE earmarked for
debt reduction diverted to backstop operating
losses in its industrial segments.
The upside risk to our view is Aviation making it
through the current recession without the
negative FCF we expect, which would allow GE's
deleveraging to progress mostly as planned. On
the downside, a prolonged recession, or
depression, could lead to limited debt
reduction if the industrial segments use up
most of the cash from the BioPharma sale.
Our 12-month target price is 15.4x GE's 2019
adjusted EPS -- below its 5-year P/E average
of 17x due to high uncertainty for the future
balance sheet and earning power.


Tuesday, June 2, 2020

My stories as a 53 year old Chinese...

June 2, 2020

Introduction

I learn to live a frugal life after November 2018, even though I do rent a small bedroom last 10 years in the city of Vancouver, but I still have so many leaks in my personal finance and decision making because of finance illiteracy. I like to write how tough it is to learn a dollar and its value as a 53 year old. 

To be an investor

2015
I purchased over 14 years old $5500 dollar used car in 2015 when I replaced my 16 year old Ford Explorer.

2018 November
I notice that I have a problem to shy away stock market from 2009 to 2019, and I still try to get in FANG as a 52 year old in 2018. I learned that I should start to work on personal finance research in November 2018.

2020 March 
I like to live frugal life, and stay away from expensive relatives. I like to have peaceful life, learn how to invest stock market.

I learned to say no and tried to discipline my relatives first time in my life. I got bullied and cursed. It is tough and I have to stay strong; First time in my adult life, I learn to be independent, and treat myself nice even if I am one person family.

2020 June 2
I know the road is tough for me as a single Chinese Canadian citizen.

Techniques I use

Memorize all common mistakes as an investor;
Learn tough part - emotion up and down because of market swings.

Wechat group leader

I tried to make it learning experience, so I have SJTU 84 class investment wechat group, I started to share my experience after March 27, 2020.

Blogs to review


I like to select three blogs to document my learnings, and then talk about issues I have.




Nightly News: Kids Edition (June 2, 2020) | NBC Nightly News

Here is the link. 


GE stock: 540 shares sell order

June 2, 2020

Introduction


It is my first stock sell since May 2019. I only made three times purchase of stocks, but this is my first time to sell stocks in less than two months. I like to learn how market works, GE stock works for me as a long term investor.

540 shares sell order





As a long term investor, I started to work on GE stock research with purchase of 60 shares. And then I had chance to review performance of GE stocks, and then asked why the GE stock had 28% loss; Based on my learning, I decided to purchase 40 shares on May 15, 2020. In less than two weeks, I noticed that GE stock had more than 14% rebound, so I learned that 5.5 should be the bottom. I purchased 500 share on May 22.

After less than three days after my purchase 500 share, GE stock went up another 14%. I thought that I am a long term investor, so I should not sell. But GE stock dropped quickly 7%, so learned that it will take some time to recover.

I will write business plan for sell of 540 shares of GE stock.


  1. I will spend time to learn more about GE business;
  2. I will purchase back GE stock 550 shares when price goes down 6.36;
  3. I will evaluate risk, and see if I should purchase more shares so that I can learn market swing better; 
  4. I like to see 100% return after two or three years, when GE aviation is back in ...
Follow up 

June 3, 2020
1:13 AM

Leetcode discuss: 414. Third Maximum Number

Here is the post.

C# SortedSet and minimum heap warm up practice in June 2020

June 2, 2020
It is an easy level algorithm. I like to review the code I wrote back in 2018 and then warmup C# SortedSet and how to implement a minimum heap using SortedSet.
Case study
The algorithm is to find third largest number in the array; if there are less than three distinct numbers, return maximum one.
How to approach the problem? Let me walk throught the test case and explain the approach.
Given an integer array, [1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10].
Design a minimum heap using C# SortedSet, which is a set with unique values, but contains numbers sorted based on binary tree data structure. I will add some detail later.
The idea is to maintain a minimum heap with size three. If a new number is added to minimum heap, if the size is not less than 3, then the minimum one is removed from the heap. This is a little tricky, but it works perfect to translate "find third largest number" into "find minimum number in minimum heap in general".
Based on the integer array, [1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10], the first three numbers are added to heap, [1, 2, 3], the fourth number is not in heap, so 4 is added to heap, minimum one with value 1 is removed; continue to work on second 4, skipped; continue to work on 5, 5 is added to heap, minimum one 2 is removed, [3, 4 , 5], until last one 10, heap is [8, 9, 10], return minimum one, value 8.
Here are highlights:
  1. Design a minimum heap using C# SortedSet;
  2. If there is less than three distinct numbers in the array, return maximum one;
  3. Always keep minimum heap size on check, make sure that it is less and equal to 3;
  4. More on step 3, if the size of heap is bigger than three, remove minimum one;
  5. Go over all the numbers in the array, put them to heap;
  6. Remove smallest one at the end.
My 2018 practice is here.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Leetcode_414_third_maximum_number_SortedSet
{
    class Program
    {
        /// <summary>
        /// code review: June 2, 2020
        /// </summary>
        public class MinHeap
        {
            /// <summary>
            /// use SortedSet to implement the minimum heap 
            /// Also, duplicate integer is removed from SortedSet. 
            /// </summary>
            public SortedSet<int> sortedSet = new SortedSet<int>();

            public void Add(int val)
            {                
                sortedSet.Add(val);                
            }

            /// <summary>
            /// SortedSet<int> default is in ascending order. 
            /// 
            /// </summary>
            /// <returns></returns>
            public int PopMin()
            {
                int minKey = sortedSet.First();

                sortedSet.Remove(minKey);

                return minKey;
            }
        }

        static void Main(string[] args)
        {
            var result = ThirdMax(new int[] { 2, 2, 3, 1 });
            var result2 = ThirdMax(new int[] { 1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10 });
            Debug.Assert(result2 == 8);
        }

        /// <summary>
        /// try to use MinHeap - August 15, 2018
        /// Requirement: 
        /// 1. Remove third maximum number;
        /// 2. If total of distinct numbers is less than three, remove maximum number. 
        /// Tips:
        /// 1. Design a minimum heap using C# SortedSet;
        /// 2. If there is less than three distinct numbers in the array, return maximum one;
        /// 3. Always keep minimum heap size on check, make sure that it is less and equal to 3;
        /// 4. More on step 3, if the size of heap is bigger than three, remove minimum one;
        /// 5. Go over all the numbers in the array, put them to heap;
        /// 6. Remove smallest one at the end. 
        /// </summary>
        /// <param name="nums"></param>
        /// <returns></returns>
        public static int ThirdMax(int[] nums)
        {
            if (nums == null || nums.Length == 0)
                return -1;

            var length = nums.Length;
            var heap = new MinHeap();
           
            int index = 0;
            for (; index < length && heap.sortedSet.Count < 3; index++)
            {
                var current = nums[index];

                heap.Add(current);
            }

            // less than three distinct number in the array - return maximum one
            if (heap.sortedSet.Count < 3)
            {
                return heap.sortedSet.Last();
            }

            // heap.Set.Count = 3
            // Let us keep min heap size as 3 all the time
            // In other words, add one number to the heap, 
            // move the minimum one in the heap as well. 
            for (int i = index; i < length; i++)
            {
                var current = nums[i];
                if (heap.sortedSet.Contains(current))
                {
                    continue; 
                }

                heap.Add(current);
                heap.PopMin();                
            }

            return heap.PopMin();
        }
    }
}


Monday, June 1, 2020

case study: lowest common ancestor in binary tree algorithm

I like to write a short case study how good the interviewee is as a senior engineer in Microsoft with more than 7 years experience.

Case study

Here is the gist.

The interviewer wrote a working solution first, and I challenged him to solve edge case if p or q is not in binary tree, and then he added a function to check p is not binary tree and do some checking before LCA is found.

After that, I asked him to think about second idea to solve the problem; he wrote the idea using stack, after 10 minutes, I stepped in to ask him to find path from root to p and root to q first, using an example, two lists and then find LCA.

He wrote the algorithm.

Here is the gist.

I reviewed the code using binary tree with test case: Root node with value 1, left child with value 2, right child with value 3, p = node with value 3, find Root to p, [1, 3]. And his code works perfectly.




My feedback as an interviewer 



I shared my showcase with the link, and also the performance of ex-Facebook engineer. Here is the link.