Tuesday, June 30, 2020

7 of the Best Penny Stocks to Buy Now

Here is the article.

With that in mind, here are seven of the best penny stocks to buy in 2020:
  • ElectraMeccanica Vehicles (NASDAQ:SOLO)
  • Silvercorp Metals (NYSEMKT:SVM)
  • Zovio (NASDAQ:ZVO)
  • Revive Therapeutics (OTCMKTS:RVVTF)
  • Coty (NYSE:COTY)
  • Husky Energy (OTCMKTS:HUSKF)
  • Harte Hanks (NYSE:HHS)


MGM stock: Trading MGM stock


Click to Enlarge
Source: Chart courtesy of StockCharts.com 
June 30, 2020
The first thing I did when I wanted to get a look at MGM stock, was look at the charts. The second thing I did was size up the balance sheet. In regards to the latter, MGM seems fine.
Current assets of $7.6 billion easily outweigh current liabilities of $2.6 billion. From that perspective, liquidity isn’t an issue for me. While cutting the dividend and working on netting out its free cash outflow, an increase in revenue should help keep the financials afloat.
As for the stock price though, it’s starting to struggle. Momentum is waning, as MGM stock breaks below the 38.2% retracement and the 50-day moving average. A correction from $24 down to the 50-day moving average just under $17 should have been a good buying opportunity. But it’s failing to hold, showing that bulls don’t have control  demand is not strong enough.
Below the 50-day moving average and investors will have to see how uptrend support (blue line) holds up. I don’t like putting all my eggs in that basket though, particularly as other more significant support levels failed.
On the upside, let’s see if MGM stock can reclaim the 50-day moving average, putting $19 to $20 back in play.
From the article

Here's what the most sophisticated investors are doing with their cash during the market rally

Here is the article.

“One is that if you don’t get into this market, you will never see these prices again because the Fed keeps pumping money into the market and inflation is going to catch up with us very soon and stocks are a safe-haven. And the other thing is that it doesn’t matter how much money is in the market, companies will have difficulty earning a profit. So that’s where we are.”




Monday, June 29, 2020

Sabr stock: Google Is Providing Search Data to Air France, Lufthansa, Other Airlines Looking to Decide Which Routes to Restart

Here is the article.

ITA Software Legacy

Marostica is the former chief commercial officer of ITA Software, which Google acquired for $700 million in 2011. One legacy of that transaction is that Google still powers flight-shopping on about a dozen airline websites, including Air Canada, Delta, American, United, Iberia, Latam, Turkish, China Southern, and China Eastern. Other Google flight-shopping partners include companies such as Northrop Grumman, Sabre’s GetThere corporate booking tool, and StudentUniverse.

Airlines selling tickets have tons of booking data, which figure into route decisions. In contrast, Google’s new tool provides data that are “super upper-funnel” concerning travelers inclinations when they are in the initial stages of planning a trip, Marostica said.

Google is not the merchant of record for flight bookings, but still there is quite a bit of data about travel intent that partners can use, he added.

Online travel agencies, meanwhile, are using the new tool for marketing purposes, Marostica said.

Google had intended to introduce the new tool later this year, but Covid-19 accelerated that timetable.

While Demand Explorer pertains to consumer intent about flights, Google could possibly expand or develop another tool based on hotel queries in Google search, Marostica said.

美股赚钱:低价位不超50元的潜力股票5只股

Here is the link.

Five stocks:

IPG - dividend 5%
XRAY -
PFE - Pfizer - 4%
PPL - 7% dividend
WBA - Walgreen


Trading: June 29, 2020


June 29, 2020

Before I go to work, I started to work on market from 6:30 AM to 9:30 AM. 

CVE.TO

290 gains, 2 business days, 290/6040 = 4.80%
I sold MGM too early, now 9:42 AM, MGM price is $16.90

2 days, 164/4755.75 = 3.4%

MGM volume 16,171,725 shares before 9:44 AM PST on June 29, 2020

Actionable Item

 I should catch up opportunity this morning, since HSE.TO is 10 cents less than the price I purchase last Friday. I should take some risk to purchase another 1000 share to 10,000 share to bet against the market go up.

CVE - add SPX next to transaction


Sunday, June 28, 2020

Mock interview: shuffle array with negative number together keep order, same as positive numbers

Here is the gist.




Stock research: 6月28日 下周走势

Here is the link.

SPX - 2950

6月28日 下周走势,精确点位 ,踏对节奏,股票退市,为什么不跌反涨?银行股的问题, 疫情对股市的影响, 美股技术分析,美股赚钱,投资美







Leetcode discuss: 84. Largest Rectangle in Histogram

Here is my post.

C# review my second practice in August 2018

June 28, 2020
Introduction
I only have two more weeks to prepare Facebook July phone screen. I came cross this algorithm, and I found my practice back in 2018. I found my blogs to document the experience, and I like to write a post to share my learning as well.
January 18, 2018 My blog about Leetcode 84. Here is the blog.
April 10, 2018, here is the blog.
August 5, 2018, here is the blog.
Case study
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.
For example, [2, 1, 5, 6, 2, 3]
largest histogram is 5 + 5 = 10
Brute force solution, choose all pair of start and end position, and then calculate the area and keep maximum.
Next, consider how to remove redundant work.
First of all, play with as many simple test cases first, and then try to find ideas to solve the problem.
[3, 2], the answer is 4.
Let us talk about this example, there are three cases to consider, [3], [2, 2], and [2] is skipped since 2 < 3. Make sure that area width 1 and 2 both are considered in comparison.
[5], the answer is 5.
[5, 3], the answer is 6.
[5, 2], the answer is 5.
[1, 5], the answer is 5.
how about [3, 2, 1]?
There are [3], [2, 2], [1, 1, 1], so the maximum one will be 4. First, 3 < 4, so [2, 2]'s area is larger than [3].
[2, 3], the answer is 4.
ascending, how to calculate area and get maximum one is 4.
[2, 3, 4], the answer is to find Math.Max{4, 3 * 2, 2 * 3} = 6. If I enumerate all possible rectangles, three are three areas with one number, two areas with two numbers, one area with three numbers.
We can argue that three areas with one number can be simplified, only check last number since it is largest one.
We also can argue that two areas with two numbers can be simplified, only check last two numbers in ascending order numbers, since rightmost one is largest one.
Based on the test case [2, 3] and [2, 3, 4], we can argue that putting all ascending numbers into stack first, once it goes down, then pop up each number in the stack, and then calculate the maximum one.
test case: [3, 4, 3, 4], maximum area is 12.
How to get the area is 12?
Let me reason one step a time.
First put [3] into stack;
Next 4, 4 > 3, so put 4 into stack; stack: [3, 4];
Next 3, so 3 < peek of top of stack 4, pop 4, calculate area with one number, [4], value should be 4; update max = 4; (why not consider 3? Since 3 < 4, no need to calculate area width 1 with a smaller value, starting from 4.)
continue to compare top of stack, 3 == 3, pop 3, calculate the area with three numbers [3, 4], so the total is 3 * 2 = 6;
Next 4, so put 4 into stack; stack [3, 4];
Now all numbers are visited in the array, pop 4, area is 4 < max = 6;
Pop 3, the stack is empty, in other words, 3 is the minimum number of all numbers in the array, termination case, 3 * length of the array = 3 * 4 = 12, which is bigger than max = 9, so max = 12.
Let me repeat the idea to solve [3, 4, 3, 4]. The idea is to cover all possible areas with different lengths, remove redundant ones if possible. So one of tasks is to find the minimum number in the array, and then area including all numbers span of width will be calculated, the area will be compared with maximum area.
How to find the minimum number of the array? When to remove numbers bigger than minimum number when going through the array iteration one by one?
Breakthrough
Go over test case [3, 4, 3, 4] and explain to myself how to find maximum area 12.
First keep a stack in ascending order, and then first two numbers into stack [3, 4], and the third number is 3, then remove numbers in the stack bigger than 3, and also calculate the area with one number, two numbers, three numbers, ...
Make sure that last number in the stack should be minimum number in the array, all numbers span will be counted to the area with minimum number, which is 12.
In detail, only the following areas are calculated and compared, [4], [3, 4], [4], [3], index value in the stack, so [1], [0, 1], [3], [2], the width calculation is challenge one for special case, last number in the stack.
The following diagram is copied from the blog I wrote in 2018.
image
I will write down step by step how to work on the example, calculate the area of largest rectangle in the histogram.
I will add more review later. Stay tuned.
Problems in my practice back in 2018
I do not understand the power of case study. I need to write down a challenge test case, and then step by step explain to myself how to solve the problem? How to improve using stack data structure? What is most challenging part in the design.
I do think that [3, 4, 3, 4] is a good test case for me to remember to solve the problem. Go over the steps to find maximum area 12.
public class Solution {
    public int LargestRectangleArea(int[] height) {
            var stack = new Stack<int>();

            var index = 0;
            var largestArea = 0;

            int length = height.Length; // 6

            while (index < length) // true; index = 1; index = 2;
            { 
                //     stack empty            going upward
                if (stack.Count == 0 || height[stack.Peek()] < height[index]) // index = 1, false;
                {
                    stack.Push(index++); // 0, index = 1;
                }
                else
                {
                    // going downward and then pop stack, calculate rectangle.
                    popStackAndCalculate(ref largestArea, stack, height, index);
                }
            }

            while (stack.Count > 0)
            {
                popStackAndCalculate(ref largestArea, stack, height, length);
            }

            return largestArea;
        }

        /// <summary>
        /// downward and then pop stack to calculate the rectangle
        /// </summary>
        /// <param name="largestArea"></param>
        /// <param name="stack"></param>
        /// <param name="height"></param>
        private static void popStackAndCalculate(ref int largestArea, Stack<int> stack, int[] height, int rightIndex)
        {
            int length = height.Length; // 6

            int lastHeight = height[stack.Pop()]; // 2
            int width = stack.Count == 0 ? rightIndex : rightIndex - stack.Peek() - 1; // 1

            largestArea = Math.Max(largestArea, lastHeight * width); // 2 * 1
        }
}


美股分析:长短期走势怎么分析?交易规则与指标谁重要?

Here is the link.

0:00 - 5:00

Investment rules:

How to time the market?

Get in/ Get out

How to control emotions and avoid mistakes?

频繁交易
重仓交易
不止损

Emotional transaction

How to stop loss? 套的很深, 最后做鸵鸟
高位做成重仓





美股分析

Here is the link.

How to set investment rules? Based on technical analysis, we should obey the rules.

I do think that it is so helpful for me to remove emotions side effects - like fear missing out, and invest $10,000 on SPX 3200 on June 5, 2020.




Saturday, June 27, 2020

Communications: Mock interview algorithm and data structure



Here is the link.


Lori Goler - lean in sharing

Here is the article. 

It was 2008: I had been working in tech for nearly 10 years, or in Facebook terms, since Mark Zuckerberg was 13 years old. I was an early Facebook user, an avid fan and excited about Facebook’s bold mission. When Sheryl Sandberg joined Facebook as Chief Operating Officer, I noticed. I knew that helping to build Facebook would be a once-in-a-lifetime experience. At the very least, I had to raise my hand at the chance.

I picked up the phone and called Sheryl. I had met Sheryl socially, but did not know her well. I was oddly surprised when I was able to reach her. I had no idea what Facebook needed. I only knew I wanted to do something that mattered. I figured I didn’t have much time, so I launched right in: “Sheryl, what is your biggest problem and can I help solve it?” We later laughed that I hadn’t even taken time to exchange pleasantries.


Facebook HR leader: Watch Facebook’s Head of People At Fortune’s MPW NextGen Summit | Fortune

Here is the link.

I like to watch Lori Goler and then I like to learn something form her. I need to have a role modal and learn better to work on my career. 

Performance review? Why? Some companies give up the performance interview? democracy?

Starting from 500 people, people are afraid to get laidoff next day. No feedback. Fairness of the process.

11:00 - 13:00
To be a learner - how to learn?


Want to Work at Facebook? See This First.

Here is the link.

Meet Lori Goler, the woman who runs “People Operations” at the world’s most admired employer.


500 people -> 8 years later -> 15,000 engineers -> how to grow?

John Battelle interviewed HR person

Pay attention how she answered all questions, and how she demonstrated good communication skills, and showed confidence and talent. 

How to end up joining Facebook? 2007    <- quick to response

Human resource management? challenging problems.

Building for scale - marketing, how to get word out?
What to mean to work for Facebook? Understand their needs? Large audience, what they want?

Builder - Look for people loving to build things, and people working on ...
Try to do that, learn. Open to learn. Rather staying on the study

You are quite clear on average people -  young, workforce, rational for that age people?

Good for all age group - show up at work
Look at data - similar to all ages - Internally ...

Values - summer interns
More focus - social capitalism -

Company?
Facebook mission - get connected, people connect to that
Facebook stories, instagram stories - really do want people to get connected

Really put people in roles - outer align - people interest
Managers - future managers - best managers - individual contributors

Continue to learn
Best place to work - what else? Secret sauce
People are very good at what they do, and people ... open company, and everything - no secret, roadmap, and other things

Move fast, impact - make good impact on the world

How to best present yourself as a candidate?
Not score, GPA, and other things - people love to build, build, and they have side projects, summer internship, and build apps and done in past roles.

Builder mentality - something broken up internal - hashtag - feed family
internal - every day and all days

Share authentically - what her illness - her plan for treatment - rally around, hundreds comment
One thousand people - people tagged the video - caught on fire

Good culture - how close we are, feel like a family

10,000 or 15,000 employees - maturity - large people - how to grow
Everyone owns Facebook culture -
What is roadmap?
Culture team - 10,000 contributes to it.

Policy?
Parental leave - some of those approaches - spread around US - inspire other organaization
primary goal

Conscious bias -

7 Common Mistakes in the Coding Interview (for Software Engineers)

Here is the link.

Strong hire signal - bias on not hiring-wrong-one
Humanity to accept the help
Ask around to get help

Show friendly professionalism
Get to know better
Subconscious help you out
Team work spirit

Not preparing - Two technical things
Team work, behavior
Through 4 hours, 4 stories to refer to
Any story - two hours - prepare stories before hand.

How did you define API?
How to use the ...

First 10 minutes -

Spending all the time on one problem - that is not the question for you, follow up question and second
Plow through the question

Make sure that you work fast, and you can pack in as much time as you can

Remember to write the code
Mix some really code with pseudo code

Take picture - credit you can get as you should be ...

Resume - write a feedback, interviewer will take resume as help to write feedback
Interviewer ...
Not focus on analysis enough - college does not teach you enough - time and space analysis
What you are even writing - even it is working
Didn't we talk about the analysis

Bonus tip:
Enjoy the lunch

Prepare technical before the interview

Notes taken by one viewer:

1. Not get a referral 2. Discouraged by refusal and stop applying. Should keep applying 3. Focus only on the tech. Should also show your friendly professionalism and that you're nice to work with 4. Not preparing. Should prepare 2 technical things + 2 personal stories to show your teamwork/leadership/communication capabilities, behavior, personalities 5. Spend time on one problem. Plow through all the question 6. Should write the code down to explain, not just hand waving. Use your resume as a reference when talking. 7. Not focus on analysis enough

Interviewing.io: Coding Interview | Software Engineer @ Facebook

Here is the link.

Two algorithms:

First one is tree algorithm - first 16 minutes

Binary tree - find average for each level
The idea is to use BFS, using queue, get count of level nodes, and sum of level node's values.

Second one is to find minimum distance to gates.

Given a 2d matrix nxm size
unfilled calls: 0
walls: -1
gates: -2

Run BFS algorithm, put all -2 on the queue, and then run BFS algorithm to mark nodes with 0 using minimum distance.

The interviewee took DFS approach which is not optimal. Last 5 minutes interviewer gave him the hint to put all -2 on the queue, and then visit all neighbors, put all those neighbors in the queue, level by level order traversal.








Interview structure: CRACKING the CODING INTERVIEW

Here is the web page. 

Here is the link of video starting from 50:00 

Here is the page of Cracking coding skills. 


Go over an example of anagrams - 

Algorithm problem 
Anagram - what is anagram - 
You need to print or return 
I told you that all algorithms work 
Dictionary 
Why to put them on server? 
Likely optimal approach is changed since server is talked about 
Cache - precompute 
Anagram server - what's the clue? 
Ex: rates -> aster, stare, taser, tears

Clue: why is it on a server? 

Interviewer is on your side

step 2: Draw an example 
big enough + general purpose
Avoid special case - People get nervous - miss some detail 
Draw an example, think about when you do this 
Make good use of example 
Most people draw example
Ex: intersection of two sorted arrays 
example - better, big, no special cases
Brain - need more reading 

Same size, one common element, ... 

Ex: counting the intersection 


What is expected : Cracking the Facebook Coding Interview The Approach

Here is the link.

52:46/ 1:49

What is expected

Be excited about hard problems
Drive!
   Keep trying when stuck
   More than just "correct"
Pay attention to me!
Write real code

Show me how you think

Drive me great solution - Keep trying when you are stuck

Red flag - Get stuck! Do not know how to solve it.

Keep trying - get stuck - it is normal to get stuck

Pay attention to me - pay attention to interviewer

Are you sure it works? Are you sure you need two arrays?



Leetcode discuss: 34. Find First and Last Position of Element in Sorted Array

Here is the link.

C# binary search algorithm practice on June 26, 2020

June 26, 2020
Introduction
Algorithm mock interview has a few things for me to work on in short term. One is to have a correct idea to solve problem, another one is to test my own code carefully, before I submit the code; Next is how to fix the problem by observing failed test cases.
I need to work on two areas. First is to test my own code, really go over simple test case, read my own code, one line a time, one variable a time.
Second is to fix timeout error, mix variable names etc.
Those two areas brought my practice on June 26, 2020 to low level. I have to humble myself and then practice more.
Binary search
It is my most favorite algorithm. I failed so many times and I like to emphasize the testing, simple thing like reading my own code after the completion of the code.
Discuss and think about carefully. That is personality I should learn and work on.
My performance
I spent near one hour to code and fix the bugs. I even ran visual studio debugger for a few minutes.
image
public class Solution {
    public int[] SearchRange(int[] nums, int target) {
        if(nums == null || nums.Length == 0)
            return new int[]{-1,-1};
        
        var start = applyBinarySearchLeftmost(nums, target); 
        var end   = applyBinarySearchRightmost(nums, target); 
        
        return new int[]{start, end};
    }
    
    /// leftmost
    /// rightmost
    // [2, 2]
    private int applyBinarySearchLeftmost(int[] nums, int target)
    {
        // apply binary search
        var length = nums.Length;
        var start = 0; // 1
        var end = length - 1; //1
        while(start <= end) 
        {
            var middle = start + (end - start)/ 2; // 0
            var middleValue = nums[middle]; // 2
            var findTarget = middleValue == target;// 2
            if(findTarget)
            {
                if(middle == start || (middle == 0 || nums[middle - 1] != middleValue))
                {
                    return middle; // 0
                }
                else 
                {
                    end = middle - 1; 
                }
            }
            else if(target < middleValue)
            {
                end = middle - 1; 
            }
            else 
            {
                start = middle + 1; 
            }            
        }
        
        return -1; 
    }
    // [2, 2]
    // [1, 2, 3]
    private int applyBinarySearchRightmost(int[] nums, int target)
    {
        // apply binary search
        var length = nums.Length;
        var start = 0; 
        var end = length - 1; 
        while(start <= end) // 0, 0
        {
            var middle = start + (end - start)/ 2; // 0
            var middleValue = nums[middle]; //0 - [1, 2, 3], 1 return [0, 1], should be [0,0], not start
            var findTarget = middleValue == target; // true
            if(findTarget)
            {   
                if(middle == end || nums[middle + 1] != middleValue)  // change middle == length - 1 to middle == end
                {
                    return middle; // 0 
                }
                else 
                {
                    start = middle + 1; // caught by [2,2], 2 - time limit exceeded, start = middle + 1, not start = middle - 1;
                }
            }
            else if(target < middleValue)
            {
                end = middle - 1; // 0
            }
            else 
            {
                start = middle + 1; 
            }            
        }
        
        return -1; 
    }
}

Leetcode discuss: 1110. Delete Nodes And Return Forest

Here is the link.

C# mock interview practice on June 26, 2020

June 26, 2020
Introduction
It is my mock interview practice and it took me more than 30 minutes to write bug-free code.
Problem statement:
Given a binary tree with distinct value in each node, given an integer array, delete those nodes in the tree, and return all trees with root node.
Things to work on:
  1. Find those nodes to be deleted;
  2. Set those nodes's left and right child to null;
  3. Also, if the node has a parent node, then the parent node should also be updated with left or right child node and set to null if need.
The solution is to run preorder traversal once, and put all integer into a hashset, and then pass parent node in function applyPreorderTraversal design.
public class Solution {
    public IList<TreeNode> DelNodes(TreeNode root, int[] to_delete) {
        if(root == null)
            return new List<TreeNode>(); 
        
        var list = new List<TreeNode>(); 
        var set = new HashSet<int>(to_delete); 
        
        TreeNode parent = null;
            
        applyPreorderTraversal(root, list, parent, set); 
        return list; 
    }
    
    private void applyPreorderTraversal(TreeNode root,IList<TreeNode> list, TreeNode parent, HashSet<int> set )
    {
        if(root == null)
            return; 
        
        var current = root.val;
        if(parent == null || set.Contains(parent.val))
        {
            if(!set.Contains(current))
            {
                list.Add(root);       
            }
        }
        
        applyPreorderTraversal( root.left, list, root , set );
  applyPreorderTraversal( root.right, list, root, set );
        
        // set null pointer 
        if(set.Contains(current))
        {
            root.left  = null;
            root.right = null;
        }
        
        if(root.left != null && set.Contains(root.left.val))
        {
            root.left = null;
        }
        
         if(root.right != null && set.Contains(root.right.val))
        {
            root.right = null;
        }
    }    
}