Saturday, July 10, 2021

Leetcode discuss | 552. Student Attendance Record II | My warmup - Hours study

July 10, 2021

Here is the link. 

Hard level algorithm | DP solution warmup | States definition | Top down

July 9, 2021
Introduction
It is risky business to invest time to work on hard level algorithms. I am not sure what is the best way to spend time to learn a hard level algorithm. I came back to warm up the algorithm, since I have a phone interview from a California startup with an office in Vancouver on July 12, 2021. Make a hard level algorithm simple. Write a story and one a time.

States | DP problem definition | How to make it clear and easy to understand?
Dynamic programming algorithm can be such a hard problem. So it is important for me to learn how to define states, three states for this algorithm, and also put together some simple questions to help myself to think top down, and how to design by coping the idea first, and then explain thinking process.

'A': Absent.
'L': Late.
'P': Present.

Rules to follow:

  1. The student was absent ('A') for strictly fewer than 2 days total.
  2. The student was never late ('L') for 3 or more consecutive days.

Case study | n = 2 | Answer: 8 cases:

Input: n = 2
Output: 8
Explanation: There are 8 records with length 2 that are eligible for an award:
"PP", "AP", "PA", "LP", "PL", "AL", "LA", "LL"
Only "AA" is not eligible because there are 2 absences (there need to be fewer than 2).

How to think about top down, and then define three states:
state 1: length of sequence
state 2: total A in the sequence
state 3: count of continuous 'L'

Top down or bottom up? | Choose top down here | Memoization

Actually think more precisely, top down, suffix not prefix of string, I should write down more precisely:
state 1: length of sequence
state 2: total A in the sequence, suffix of sequence
state 3: count of continuous 'L', suffix of sequence

Last char can have three cases: 'P', 'A', 'L'
"?P", so top down, the existing sequence "P", no 'A', 0 of consecutive 'L'
"?A", so top down, the existing sequence "A", 1 'A', 0 of consecutive 'L'
'?L", so top down, the existing sequence "A", 1 'A', 1 of consecutive 'L'

I just work on simple analysis, so the answer of n = 2 should be "??", so top down, the existing sequence "", no 'A', 0 of consecutive 'L'.

Another two tips to help warmup rules:

  1. Consecutive 'L' may be reset, for example, "PPLLPLL", top down, 1 to 2 consecutive 'L', and then P is the third char, reset to 0 of consecutive 'L'
  2. Total count of 'A' always increases, valid possible count of 'A' are 0 or 1, for example, valid sequence "PPAP", starting from rightmost, from 0 to 1, and stay as 1 until first char 'P' is visited.

So first define the function:

private int helper(int n, int chosenA, int continuousL, int[, ,] cache)

n = 2,
"??", top down, the suffix string is empty, so there is no 'A', 0 is the length of continuous 'L'.

return helper(n, 0, 0, cache);

If I can understand the above statement and reasoning behind. Continue to read the following analysis.

Last char can have three choices, 'A', 'L', 'P'.
If suffix string already has 'A', then there is no option for 'A', otherwise 'A' can be taken. So it is easy for me to read the following statements in the function:

 if (chosenA == 0)
 {
	// add 'A', reset continuousL = 0
    // n -> n - 1
    result += helper(n - 1, chosenA + 1, 0, cache);              // Choose 'A'
    result %= mod;
 }

If I can understand the above statements, then I think that I can work independently and write a working solution. Otherwise go back to problem statement, and then read again.

Actionable Items
Change variable name chosenA to suffixA, variable name continuousL to suffixContinuousL.

Stay tuned. I will add more detail in short future.

public class Solution {
    /// <summary>
        /// July 9, 2021
        /// How to solve this problem using three dimension dynamic programming? 
        /// 1. First, define states, three states, length of sequence, number of days absent, and maximum continuous 'L';
        /// 2. Second, try to build recurrence formula. 
        /// Not allowed: 
        ///   1. Two days absent
        ///   3. Three day continuous late
        /// Still confused, review the discussion post here:
        /// To save time, only work on length = 2, make sure that total found is 8.
        /// "PP", "AP", "PA", "LP", "PL", "AL", "LA", "LL"
        /// if n = 0, then "" is only option, empty string. 
        /// if n = 2, then cache's state - length of sequence should be 3, allow 0, 1, 2 three options. 
        /// Argue that return should be help(2, 0, 0, cache), chosenA = 0, continuousL = 0 as well. 
        /// 
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public int CheckRecord(int n)
        {
            var cache = new int[n + 1, 2, 3];

            for (int row = 0; row < n + 1; row++)
            {
                for (int col = 0; col < 2; col++)
                {
                    for (int L = 0; L < 3; L++)
                    {
                        cache[row, col, L] = -1;
                    }
                }
            }

            return helper(n, 0, 0, cache);
        }       

        /// <summary>
        /// Returns the number of ways to create a string of 
        /// length n with characters 'A', 'L', 'P' 
        /// while having <= 1 total 'A's and <= 2 consecutive 'L's.
        /// n = 0, return 1, ''
        /// n = 1, return 3 'A' or 'P' or 'L'
        /// n = 2, last option can have three choices, 'A' or 'P' or 'L'
        /// Think about top down 
        /// return helper(n, 0, 0, cache), length of sequence is n, and no 'A' is used, no 'L' is used. 
        /// ?'A' -> subprobem -> total A used should be chosenA + 1
        /// ?'L' -> subproblem -> if it is allowed - check first, and then update count
        /// ?'P' -> subproblem -> always ok, reset continuousL, chosenA - no change
        /// </summary>
        /// <param name="n"></param>
        /// <param name="chosenA"></param>
        /// <param name="continuousL"></param>
        /// <param name="cache"></param>
        /// <returns></returns>
        private int helper(int n, int chosenA, int continuousL, int[, ,] cache)
        {
            int mod = 1000 * 1000 * 1000 + 7;
            // base case - 1, 
            if (n == 0)
            {
                return 1;
            }

            if (cache[n, chosenA, continuousL] != -1)
            {
                return cache[n, chosenA, continuousL];
            }

            int result = 0;

            if (chosenA == 0)
            {
                // add 'A', reset continuousL = 0
                // n -> n - 1
                result += helper(n - 1, chosenA + 1, 0, cache);              // Choose 'A'
                result %= mod;
            }

            if (continuousL < 2)
            {
                // add 'L', continuousL++
                // chosenA - no change 
                result += helper(n - 1, chosenA, continuousL + 1, cache);    // Choose 'L'
                result %= mod;
            }

            // add 'P'
            // reset continuousL = 0
            // chosenA - no change 
            result += helper(n - 1, chosenA, 0, cache);                      // Choose 'P'

            result %= mod;

            // memoization - save to cache
            cache[n, chosenA, continuousL] = result;

            return result;
        }
}

Benzinga | Melanie Schaffer | Graybug Vision Shorts Got A Serious Squeeze: What's Next? | Ideas to work on

July 10, 2021

Introduction

I like to get a few ideas how to work on gray stock better with possible short squeeze. I like to read the article carefully. 

Melanie Schaffer | Benzinga Staff Writer 

I like to read more articles written by Melanie. Here is the link. 

Graybug Vision Shorts Got A Serious Squeeze: What's Next?

Graybug Vision Inc GRAY 1.77% has not released any news since it printed its first-quarter 2021 earnings results May 12, but that didn’t stop the stock from closing up 22% on Thursday and soaring further Friday morning. 

The beaten-down stock went public on Sept. 25, 2020 at $19 and climbed almost 100% higher over the following two months to reach a Nov. 23 all-time high of $37.88.

The clinical-stage biopharmaceutical company’s stock then double-bottomed on May 14 and May 24 at $3.46 after a monthslong 90% cliff dive.

There may be a short squeeze in the cards for Graybug Vision: it has all the classic characteristics of other recent short squeeze targets such as Senseonics Holdings Inc. SENS 3.12% and World Wrestling Entertainment, Inc. WWE 1.13%. 

  • Small float: Graybug Vision has only 7.8 million shares available.
  • High levels of ownership: Institutions and insiders own 81.15% of Graybug Vision’s float, with insiders owning 10.47% and institutions owning 70.68%.
  • High short interest: As of May 28, 1.24 million, or 10.74% of the stock’s float, is held short.

The Graybug Vision Chart: On Thursday, massive bullish volume entered Graybug Vision’s stock and drove it up over a resistance level near the $5 mark. The move helped the stock put in a higher high on the daily chart, confirming the downtrend is over.

On Friday, Graybug Vision gapped up about 18% before hitting resistance at $6.97 and prompting a group of sellers to came in and drop the stock down to fill the gap.

It’s not a bad thing for the bulls that Graybug Vision has filled the lower gap. Gaps fill 90% of the time, and leaving a gap below can make traders nervous. Graybug does have an overhead gap starting at $11.12 all the way up to $14.52, which is also good for bullish traders, as it's likely the stock will trade back up in that range in the future.

Thursday’s move also helped Graybug vision to close above the eight-day and 21-day exponential moving averages (EMAs) and for the eight-day EMA to firmly position itself over the 21-day EMA, which gives bulls more confidence.

Since Graybug has not yet traded for 200 days, the 200-day simple moving average (SMA) isn’t available as an indicator but traders can use the 50-day SMA as well.

On Friday morning, Graybug Vision was trading about 20% above the 50-day SMA which indicates sentiment in the stock is bullish.

Bulls want to see consolidation on low volume and for Graybug Vision’s stock to hold above support at $5.04.

After a period of consolidation, the stock could make another run up toward the $7 mark and, if it can push over that level, it would become support. Graybug Vision could then make a move up toward $8.65.

Bears want to see big bearish volume enter the stock to drop it back down under $5. If the stock was unable to hold the level it could fall down to $3.51, which would also cause Graybug Vision to lose support of the eight-day and 21-day EMAs.

GRAY Price Action: Shares of Graybug VIsion were trading down 1.26% at $5.46 at last check. 

My position | July 10, 2021 | Risk management 

I like to control risk to lose all the capital around $11,000 US dollars. Right now the loss is around $3000 us dollars. 

It is important for me to learn the business. Play safe and short squeeze may not come again, I have to learn better about Graybug vision and the research on AMD disease. 


Feb. 23, 2024

I have to take some time to review my thoughts back in 2021. 

I like to control risk to lose all the capital around $11,000 US dollars. Right now the loss is around $3000 us dollars. 

It is important for me to learn the business. Play safe and short squeeze may not come again, I have to learn better about Graybug vision and the research on AMD disease. 

My advice after three years:

  1. GRAY stock - $3000 dollars loss, I should stop loss and then say goodbye on this stock. 
  2. I have problems to handle gambling behavior 
  3. Need to learn how to discipline myself 
  4. $3000 US dollars is a lot of money, why I choose to take risk, I should learn how to protect my capital first. 

Thursday, July 8, 2021

美股跟跌! | July 8, 2021 | 2022年1月,美联储将宣布缩表计划 | 席勒市盈率均值为25.5倍 | 37.99 -> 25.5

July 8, 2021

Here is the article.

Here are highlights:

  1. 过去20年席勒市盈率均值为25.5倍,倘若美联储缩表后,开启加息进程,美股整体估值回归均值是大概率事件。从当前的37.99倍跌至25.5倍,意味着美股整体可能最多下跌36%。
  2.  2022年1月,美联储将宣布缩表计划。也可以认为,影响全球资本市场的超级大风暴临近了!满打满算,还有6个月时间

超级风暴临近了!最近影响全球股市最大的因素是什么?美联储宣布缩表计划。最新数据显示,美国非农就业市场总体已恢复95.57%,2022年1月正式缩表可能性极大。据美国劳工部数据,美国6月新增就业85万人,高于市场预期的72万,但失业率从5月份的5.8%上升至5.9%,此外,5月非农数据上修至58.3万。

2014年1月美联储正式宣布缩减购债,每月购买美国国债规模从450亿美元削减至400亿美元,此后按每月缩减100亿美元的购债节奏逐步退出。2014年1月开始Taper时就业市场恢复程度为99.38%,若以此为基准,则本轮正式开始削减购债时就业人数应为15098万人,若以6月新增85万人的月新增人数计算,需6个月,也就是美联储将于2022年1月正式开启Taper。有市场分析师认为,美联储缩表过程中,美股未必会下跌,影响最大的反而是美联储宣布缩表的那一刻。按照这种说法,市场广泛预期为2022年1月,美联储将宣布缩表计划。也可以认为,影响全球资本市场的超级大风暴临近了!满打满算,还有6个月时间。

昨日港股暴跌,美股跟跌!7月8日消息,美股周三收高,纳指与标普指数再创历史新高,大型科技股领涨。今日开盘,恒生指数低开0.28%,随后跌幅扩大。截至收盘,恒生指数跌2.89%,报27153.13点;国企指数跌3.22%;红筹指数跌2.08%。

美股跟跌。北京时间7月9日凌晨,美股周四收跌。对全球经济复苏可能受阻的担忧令股指承压。多国正在应对新冠病毒德尔塔变种感染病例的反弹。日本在奥运会前宣布进入紧急状态、奥运会将禁止观众入场。美债收益率大幅下降。道指跌259.86点,或0.75%,报34421.93点;纳指跌105.28点,或0.72%,报14559.78点;标普500指数跌37.31点,或0.86%,报4320.82点。

A股不涨,非常聪明!截至北京时间7月8日收盘,沪指跌0.79%,报收3525点;深成指跌0.38%,报收14882点;创业板指涨0.69%,报收3432点。沪深两市成交额接近1.2万亿元,连续第六个交易日突破一万亿元。北向资金净流出17.01亿元。

笔者认为,市场永远都是最聪明的。近期A股市场跌跌不休,连续第六个交易日突破一万亿元。沪指也曾多次短暂突破3600点,但很快失守。7月9日早盘,上证综指甚至一度下探至3485点附近,但很快回升至3500点上方。有人认为我看空中国股市,其实并非如此。或许是冥冥之中,A股市场感受到了美联储缩表的暗黑破坏力。7月8日,上交所最新数据显示,科创板总市值47640.27亿元,平均市盈率73.11倍。7月9日价值大师网的席勒市盈率显示,当前美股席勒市盈率为37.99倍。美股泡沫接近历史最高位,科创板整体泡沫同样惊人。

耶鲁大学著名经济学教授罗伯特·席勒发明了席勒市盈率来衡量市场估值。席勒市盈率是比市盈率更合理的市场估值指标,因为它消除了业务周期中利润率变化所引起的比率波动;这与基于总市值占GDP比率的市场估值相接近,该指标中利润率的变化也不会产生影响。席勒市盈率历史最高值发生在1999年12月,高达44.2倍,彼时恰逢美国科技股泡沫巅峰期。

过去20年席勒市盈率均值为25.5倍,倘若美联储缩表后,开启加息进程,美股整体估值回归均值是大概率事件。从当前的37.99倍跌至25.5倍,意味着美股整体可能最多下跌36%。

  倘若美股整体可能最多下跌36%,那么A股会跌多少?这个没有人能够准确回答。跌幅肯定不会少。所以,近期A股不涨,多次攻下3600点,很快就退守3500点附近,这是非常聪明的!在资本市场,我们永远都要怀有敬畏之心。市场永远都是最聪明的。

The Transformative Power of Walking | Sandra James | TEDxCarsonCity | City of Vancouver - how to build community?

July 8, 2021

Here is the link. 

Vancouver BC City Planner, Sandra James gives examples of how making a community more walkable, can change the social fabric of a neighborhood or a community. Sandy James is irrationally passionate about sustainably smart walkable communities. As a city planner for the City of Vancouver Sandy championed locally scaled neighborhood projects that virally became city policy in Vancouver and other cities. Working collaboratively with engineering staff Sandy developed the innovative 140 kilometer “green street” sustainable network of connected parks, streets and places where pedestrians have priority. Known as the “pickpocket of city hall” for her ability to find financing, Sandy was named Neighborhood Planner of the Year” by the Vancouver Sun newspaper for her work with communities. Sandy believes that promoting walkability is socially and morally the right thing to do, and chaired the international Walk 21 Conference in Vancouver in 2011. Sandy is a Director of Walk Metro Vancouver, which encourages best practices for the development of walkable places and spaces, creating communities we want to live in. This talk was given at a TEDx event using the TED conference format but independently organized by a local community. Learn more at http://ted.com/tedx

Born to Walk | Born to Walk: The Transformative Power of a Pedestrian Act Hardcover – April 1 2015 by Dan Rubinstein (Author) | 26 minutes interview

July 8, 2021

Here is the link. 

Mundane mode of transportation or mind-expanding journey, walking is one of humanity's simplest accomplishments. From walking with police on the beat in Philadelphia, to hiking with war veterans from Iraq and Afghanistan, Ottawa-based editor and writer Dan Rubinstein explores the transformative properties involved in travelling by foot. The Agenda in the Summer welcomes Rubinstein to take a stroll through the health and societal benefits of walking in his book, "Born to Walk: The Transformative Power of a Pedestrian Act."

The Gift of Walking | EverybodyWalk | Benefits of walking

July 8, 2021

Here is the link. 

Kaiser Permanente Chairman and CEO George C. Halvorson discusses the gift of walking. Discover how walking 30 minutes a day, five days a week can help reduce the rate of diabetes, strokes, heart disease, hypertension and more. The benefits of walking are good for all, and can also help combat breast and prostate cancer. Beyond the physical benefits, walking can have a major positive impact on depression by creating positive neurochemicals. And you don't have to be a regular at the gym to get the benefits. You can fit walking into your daily routine and experience the benefits with shorter walks throughout the day. The benefits are multiple--and it's easy and free to do. Walking is our gift. Walking is our strength. Walking makes us strong. So let's walk.

The Importance Of Walking → Improve Your Overall Health

July 8, 2021

Here is the link. 

Learn about the importance of walking every day and how it can DRASTICALLY improve your overall health. Get our Fit Father 30-Day Fat Loss Program here → https://www.fitfatherproject.com/yout... Get our Fit Father Old School Muscle Building Program here → https://www.fitfatherproject.com/yout... Subscribe to our channel here → https://goo.gl/wxghQ5 Our FREE resources: 1-Day Weight Loss Meal Plan → https://www.fitfatherproject.com/yout... 24-Min Fat Burning Workout → https://www.fitfatherproject.com/yout... 5 Best Muscle Building Exercises → https://www.fitfatherproject.com/yout... "Walking is the best medicine" - Hippocrates Walking is essential for good health. Walking research is very clear. If you take a 30-minute walk each day, your heart will be dramatically healthier. As you walk, your heart pumps in a nice and relaxed manner, circulating oxygen-rich blood throughout your body. When your body is receiving this vital oxygen-rich blood and nutrients, your body and tissues stay younger and healthier. The walking benefits for men are infinite. Did you know you can lose weight walking? A 30-minute walk can boost your metabolism for up to 12 hours after the walk! Pairing a healthy diet with a 30-minute walk can help you lose weight without exercise. Additional benefits of walking include strengthening your bones and improving your attention and memory. Taking a walk after eating a meal is a great idea. Walking helps to decrease the blood sugar spike that happens after eating a meal. Start taking a walk every day and let us know how you feel in the comments below! 👇 If you feel your lifestyle could use an improvement, then check out our FF30X 30-Day Transformation Program at → https://www.fitfatherproject.com/yout... If you want to start putting on muscle TODAY, check out our Fit Father Old School Muscle Building Program at → https://www.fitfatherproject.com/yout...


What Will Happen to Your Body If You Walk Every Day

 July 8, 2021

Here is the link. 

Walking is a totally free, easy exercise that requires little effort, and benefits not only your physical but also your mental well-being. If you’re looking for a simple yet very effective way of losing weight and improving your overall health, walking is something just for you. People who are physically active throughout their life are much less prone to this disease than those who have a more sedentary lifestyle. And that’s because they have more volume in their hippocampus, the part of the brain responsible for verbal memory and learning. A daily half-hour walk helps avoid serious problems, like coronary heart disease to name one, by lowering high blood pressure and cholesterol levels and improving blood circulation. Because of better-quality and deeper breathing, some symptoms associated with lung disease can show significant improvement thanks to walking. Muscle tone and weight loss is also totally achievable through simple walking. Find your optimal pace, but don’t break out into a jog. This sort of speed walking is low impact and doesn’t require any recovery time, which means no sore muscles to keep you from getting out and walking the next day. The Arthritis Foundation recommends at least 30 minutes of moderate walking a day to reduce pain, stiffness, and inflammation in the joints. Building strong bones will help you prevent osteoporosis and reduce bone loss. Walking contributes to better blood circulation within the spinal structures, pumping important nutrients into the soft tissues and improving posture and flexibility, both of which are vital for a healthy spine. A group of researchers at Iowa State University worked with hundreds of college students. Walking changed their mood for the better, even though no one warned them it could do so. If you still don’t feel motivated enough to start walking for your health, try joining a class or find a buddy who also wouldn’t mind getting all the benefits of walking. Another idea could be to hire a personal trainer. Music: https://www.youtube.com/audiolibrary/... TIMESTAMPS Brain-boosting effect 0:45 Improved eyesight 1:44 Prevention of heart disease 2:47 Increased lung volume 3:14 Benefits for the pancreas 3:51 Improved digestion 4:23 Toned muscles 4:59 Sturdier bones and joints 5:45 Back pain relief 6:10 A calmer mind 7:04 Bonus: the FIT formula 8:00 SUMMARY -Walking prevents the early onset of dementia, reduces the risk of developing Alzheimer’s disease and improves your overall mental well-being by reducing stress and releasing endorphins. -Get on the road to improve vision and protect your eyes now from potential problems, such as glaucoma, in the future. -Walking is no less effective than running when it comes to the prevention of heart disease and stroke. -Walking is an aerobic exercise, which means that it increases oxygen flow in the bloodstream and helps eliminate toxins and waste, which is great for your lungs. -Walking for exercise is a surprisingly more effective way to prevent diabetes than running is. -Just half an hour of walking every day not only lowers the risk of developing colon cancer but also improves digestion and regulates bowel movements. -Just 10,000 steps a day can be just as effective as a full-blown workout at the gym, especially if you add some intervals or uphill walking. -Walking can provide more joint mobility, prevent the loss of bone density, and even reduce the risk of fractures. -Walking is a real life-saver for those who experience back pain during more challenging high-impact exercises. -Walking improves depression symptoms in patients with MDD, just imagine how easily it could help us cope with just feeling down or exhausted. -Keep in mind the FIT formula. It stands for Frequency (how often), Intensity (how fast), and Time (for how long). Subscribe to Bright Side : https://goo.gl/rQTJZz ---------------------------------------------------------------------------------------- Our Social Media: Facebook: https://www.facebook.com/brightside/ Instagram: https://www.instagram.com/brightgram/ 5-Minute Crafts Youtube: https://www.goo.gl/8JVmuC