Monday, October 28, 2019

1238. Circular Permutation in Binary Representation

Here is the discussion post.

C# Design algorithm using DFS similar to Sudoku solver

It is a medium level algorithm which can be solved using depth first search. The challenge part is to work on bit manipulation, how to change one bit from index = 0 to index = 15?
Case study:
I need to warmup bit manipulation to learn to solve two problems in the following:
  1. Change one bit - how to change it?
    Use bit operator XOR. As we know, 0 ^ 0 = 0, 0 ^1 = 1, 1 ^ 1 = 0; and there are 16 bits to alter, and we can use left shift operator to generate an integer to set nth bit to 1 whereas n is from 0 to 15. In other words, I have to come out the express 1 << i.
    So, the answer is last ^ (1 << i), whereas is from 0 to 15.
  2. How to prove two numbers are the same except one bit?
    Assume that m and n only have one bit different, so m ^ n = 2^p, p is from p to 15. And p & (p - 1) = 0 <=> all bits from 0 to p should be 0.
Here are highlights:
  1. Understand how to run DFS to search all possible paths until one path is found.
  2. Work on DFS search - base case, backtracking, mark visited using HashSet to avoid deadloop;
  3. Time complexity and space analysis is similar to my favorite algorithm Sudoku solver.
Actionable Items
I could not solve the algorithm in weekly contest 160 on Oct. 26, 2019. I spent over 20 minutes to analyze, but I could not come out using DFS algorithm to work on all bits from 0 to 15.
I have to practice more often in weekdays, solve more medium algorithms.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

        /// <summary>
        /// 1238 Circular Permutation in Binary Representation
        /// The idea is similar to Sudoku solver; Each step using DFS to search all options. 
        /// </summary>
        /// <param name="n"></param>
        /// <param name="start"></param>
        /// <returns></returns>
        public IList<int> CircularPermutation(int n, int start)
        {
            var result = new List<int>();

            var set = new HashSet<int>();
            result.Add(start);
            set.Add(start);

            runDFS(n, set, result, start);
            return result; 
        }

        /// <summary>
        /// similar to Sudoku solver
        /// backtracking 
        /// DFS path - mark visited
        /// </summary>
        /// <param name="n"></param>
        /// <param name="hashSet"></param>
        /// <param name="result"></param>
        /// <param name="start"></param>
        /// <returns></returns>
        private static bool runDFS(int n, HashSet<int> hashSet, IList<int> result, int start)
        {
            if (hashSet.Count == (int)Math.Pow(2, n))
            {
                int x = result[result.Count - 1] ^ start; // XOR operator - first and last are different
                return (x & (x - 1)) == 0; 
            }

            var length = result.Count;
            int last = result[length - 1];

            for (int i = 0; i < 16; i++)
            {
                int next = last ^ (1 << i); // XOR operator - change ith bit 
                if (next <= (Math.Pow(2, n) - 1) && !hashSet.Contains(next))
                {
                    hashSet.Add(next);
                    result.Add(next); 

                    if(runDFS(n, hashSet, result, start))
                    {
                        return true; 
                    }

                    hashSet.Remove(next);
                    result.RemoveAt(result.Count - 1);
                }
            }

            return false; 
        }
    }
}


If you had bought 100 shares of Microsoft 25 years ago ...

Here is the article written on March 10, 2011, 8:52 AM PST

I like to write down some notes.

1. Thursday, March 13, 1986, Microsoft, $61 million - initial public offering, 30 years old Bill Gates

2. A story to tell, if 100 share with $21 offer price was purchased in 1986. After 25 years, it worths 0.75 million dollars.

100 share
 $21 offer price
25 years

After 25 years
2011,
28,800 shares
nine stock splits,
0.75 million dollars

Nine stock splits - Here is the page to look up


Advice From Warren Buffett

Here is the link.


Sunday, October 27, 2019

Stock Multiples: How to Tell When a Stock is Cheap/Expensive

Here is the link.


Reasons To Avoid Index Funds (ETFs)

Here is the link.


Investing in the S&P 500

Here is the link.

Own 500 of the 3500 - 80% capital

Human decision - what 500 companies go to S&P 500 index


Renting vs. Buying a Home: The 5% Rule

Here is the link.

You can't compare rent to a mortgage payment. This way of thinking about the rent versus buy decision is extremely flawed. Comparing a mortgage payment to rent is not an apples to apples comparison. In order to properly assess the rent versus buy decision, we need to compare the total *unrecoverable costs* of renting to the total unrecoverable costs of owning.

Preparing for the Recession

Here is the link.

On average, stock returns during US recessions have been negative for a globally diversified Canadian investor. Nobody wants to lose money, so it is common to wonder what can be done to avoid the potentially negative stock returns that often come with a recession.


Is Investing Risky?

Here is the link.

It is common to think about risk in terms of total loss. You invest your money in a stock, things turn sour, and your money is gone. This can happen when you invest in a single stock, but when you properly diversify your investments it is much less likely.

-
your time horizon
your psychological tolerance for volatility

compensated risk - stock price - market value - discount

Diversified stock

skewness - normal / positively skewed



7 Things I Will NEVER Spend Money On Again - HOW TO PRACTICALLY SAVE MORE MONEY

Here is the link.

Have you ever asked yourself if you could be spending your money more wisely? Do you find that no matter how hard you try, at month’s end, you have next to no money to show for all the hard work you put in? What if I told you that there were 7 things you could cut from your budget right now that would save you a significant amount of money every month helping you reach your financial goals much sooner? Well in this video, I will tell you 7 things I will never spend money on again.

1. Banking fees
2. Gambling
3. Credit card interest charges
4. Cable
5. Expensive gym membership
6. Extended warranties
7. Trying to impress people

7. Trying to impress people

We buy things we don't need, with money we don't have, to impress people we don't like


10 Lessons School NEVER Teaches You About Life

Here is the link.

“Education is what remains after one has forgotten what one has learned in school.” Did you ever hear this kind of famous quote from Albert Einstein? Kind of funny isn't it? That one of history's greatest geniuses would suggest that what you learned in school might not actually be the most important thing? But, considering how smart he was, I'm willing to believe he might've been right.

1. Perspective Is Key 2. Not Everything is About You 3. Good Friends Are Very Important 4. You are Responsible for your Happiness 5. Your Job Title doesn’t Define Who you are 6. Independence is Liberating 7. You Have Absolutely Nothing to Lose 8. Sometimes, Collaboration is more Important than Competition 9. Food and Sleep are Medicine 10. Life is not Fair, Get Used to It!

5 Habits keeping You Poor

Here is the link.

In this video, I will share with you 5 habits keeping you poor so that you can avoid these mistakes and realize financial success in your life. Habit 1: Using credit cards Habit 2: Spontaneous Shopping Habit 3: Not Budgeting Habit 4: Not Investing Habit 5: Not tracking Your Expenses


why do you buy impulsively things you do not need?

A good rule of thumb is always carrying a shopping list.

Habit 3:
Not budgeting

Only humans do not budget things.

Habit 4: Not investing

Roadmap to success

You need to invest. This is essence of content ...
rental property, stock, etc.

These passive income

Habit 5: Not tracking your expenses

Just imaging having all the expenses you make


HOW TO BECOME SUCCESSFUL - The 10X Rule by Grant Cardone Animated Book Summary

Here is the link.

In this animated book summary we take a look at Grant Cardone's The 10X Rule. He says that you must take massive action in order to become successful.

2:57/ 6:13
2. Retreat

- Fear negative experience as a result of taking action
- "I lost money in the stock market so I'm never investing again"
- "Most marriage fail so I' m staying single"
- "Owning a business is too risky"

1. No action
2. Retreat
3. Normal Action
4. Massive action

- Most natural level of action
- Intense energy and interest
- CEO's, executive, entrepreneurs, athletes, musicians, etc.

Rule #3: Eliminate ...

Fear only exits during situations that matter!

Fear - False Events Appearing Real

Fear's fuel: time to magnify

First step = always ...




The 10X Rule, by Grant Cardone | Animated Summary | Between the Lines Book Summaries and Reviews

Here is the link.

Humans have a tendency to set too low of goals

1. Success is important
2. Success is your duty
3. There is not shortage of success

In order for you to win, some one else does not have to lose.

The four degrees of action

No action
Reverse action
Average action
Massive action

Massive action leads to new problems

Forget about competition
There's too much competition being average

Fear
Understand what fears means

Fear means it's time to act
Commit first, figure out the detail later

Goal settings and getting started
Goals/ actions
Don't get lost in the details
Do not prematurely value the outcome of your actions

True motivations comes from the inside

Show up, be all in, and trust ...


PNTV: The 10X Rule by Grant Cardone

Here is the link.

The 10X Rule
1.Action: 4 directions
2. Goals
3. Obsession
4. Starve fear
5. Smokey

Massive action





Grant Cardone: 10X the difference between success and failure

Here is the link.


How I Generated Near $1mill In Gross Revenue w/ Grant Cardone's 10x Rule

Here is the link.


Grant Cardone: The 10X Rule Book Summary

Here is the link.

I like the presentation. Very detail in the notes about "The 10X rule"

The 10X Rule: The Only Difference Between Success and Failure by Grant Cardone

Here is the link.


THE 10X RULE SUMMARY (BY GRANT CARDONE)

Here is the link.

Here is the book called The 10X Rule: The only difference between success and failure.

10x goals x 10x actions = 100x the results. In this animated video summary, I will share my top 5 takeaways from Grant Cardone’s The 10x Rule. Hard work pays off.
Top 5 takeaways from The 10x Rule: 00:40 1. 10x Goals Bootstrap Your Success 03:01 2. 10x Action is Required 05:27 3. Create Your Own Luck 07:51 4. FEAR 09:24 5. Don’t Compete. Dominate!

How to build wealth and grow rich from 2010 to 2019?

Oct. 27, 2019

Introduction


It is hard than I thought to go over one year personal finance research. I like to write a blog called how to build wealth and grow rich from 2010 to 2019.

Year 2010 and city of Vancouver


I chose to land in the city of Vancouver back in 2010 April. I like to travel once cross USA to visit a lot of national parks. I did not think about too much about career, job search. I had hard time to build a career as a software engineer. I just got an immigration visa based on a skilled software engineer.

The condo in the city of Surrey, brand new is around $115,000 dollars. I wrote a blog to document my asset when I landed in Canada in 2010.

Year 2011 - 2014


I decided to get Canada citizenship as soon as I am qualified. So I did not set up a goal to be a millionaire as I was in my 45 years old. I was not so sure how good I could do in terms of a software programmer, and also I was a new immigrant.

I started to spend money on USA shopping trips, and then go back to old habit.

In Dec. 2014, I got my Canadian citizenship after I waited over 12 months. The process was so long and also I had hard time to rush myself to prepare my Citizenship test last two weeks before the test.


Actionable Items


My goal is changing from 2010 to 2019.

2010 - find a job
2011 -
2012 - Vacation to China, help my mom overcome difficulty
2013
2014 - work on Canadian citizenship, tennis, weight control first time
2015
2016 - work on Amazon onsite
2017 -
2018 - work on Amazon onsite, personal finance
2019 - work on Amazon onsite, Facebook onsite, how to be a millionaire in next 10 years?



Nassim Nicholas Taleb wikiped

Here is the article.



Writing career[edit]

Taleb's five volume philosophical essay on uncertainty, titled the Incerto, covers the following books: Fooled by Randomness (2001), The Black Swan (2007–2010), The Bed of Procrustes (2010), Antifragile (2012), and Skin in the Game (2018). It was originally published in November 2016 including only the first four books. The fifth book has been added in August 2019.
His first non-technical book, Fooled by Randomness, about the underestimation of the role of randomness in life, published in 2001, was selected by Fortune as one of the smartest 75 books known.[50]
His second non-technical book, The Black Swan, about unpredictable events, was published in 2007, selling close to 3 million copies (as of February 2011). It spent 36 weeks on the New York Times Bestseller list,[51] 17 as hardcover and 19 weeks as paperback,[21][52] and was translated into 31 languages.[21] The book has been credited with predicting the banking and economic crisis of 2008.[17][53]

FOOLED BY RANDOMNESS SUMMARY (BY NASSIM TALEB)

Here is the link.


magicformulainvesting.com

Here is the website.

The book has a sold record 300,000 copies. I learned about the book from video called "The little book that has beats the market (by Joel Greenblatt").



What Is Magic Formula Investing?

Oct. 27, 2019

Introduction


I got the concept from 13 minutes video called "The little book that beats the market (by Joel Greenblatt). The concept is called the magic formula. I like to look into the concept and then google the concept.


A short research


Here is the article I like to read.


Saturday, October 26, 2019

Burton Malkiel: How to Invest

Here is the link.

Princeton economist Burton Malkiel says simplicity is key to a successful portfolio. He discusses emerging markets, index funds, and more with Eric Schurenberg.

You get what you don't pay for.


100 BAGGERS: STOCKS THAT RETURN 100-TO-1

Here is the link.


Weekly contest 160

Oct. 26, 2019

Introduction


It is my favorite weekly contest. I only solved the first algorithm in the contest, and I like to write a blog about this contest.

My performance


Here is my performance.


Actionable items


I worked on those two medium algorithms in the contest, but I did not come out working solution in the contest.

I need to practice more medium algorithms in weekdays. So I will not feel so stressed to work on medium level algorithms in the contest.


Amazon stock study - Oct 26, 2019

两家云服务增速都放缓

24日美股盘后,微软和亚马逊都发布了最新的季度财报。

据《21世纪经济报道》梳理,在截至9月30日的微软2020财年第一季度,该公司的智能云业务表现抢眼,营收达108亿美元,同比增长27%。其中,得益于Azure营收59%的增长,服务器产品和云服务营收增长30%,企业级服务营收增长7%。

不过,尽管本财季Azure营收依然保持了较高的增长,但这一增速继续呈现逐渐放缓的趋势。目前这部分业务营收已连续8个季度增速下降(含持平),上一财年同期增速为76%。

另一方面,亚马逊本财年第三季度的利润同比下降26%,至21亿美元,合每股4.23美元,低于分析师普遍预期的每股4.59美元,这也是该公司自2017年以来首次出现季度利润同比下滑。

与此同时,亚马逊AWS云服务当季营收为90亿美元,略低于分析师91亿美元的预期,其35%的增速也创2015年有数据披露以来的新低。

CNBC报道称,过去4年,亚马逊的大部分营业利润来自AWS云服务,因此这部分业务的增长放缓,可能会拖累该公司未来的收益。

Facts:

亚马逊本财年第三季度的利润同比下降26%,至21亿美元,合每股4.23美元


Microsoft is 2% of S & P 500 index

Oct. 26, 2019

Introduction


It is my job to work on individual stock research. I like to put 20 stock on my watch list or wish list. I purchased MSFT stock back in 2001, and I like to put MSFT stock in my watch. When should  invest MSFT stock?

Microsoft stock research


I did purchase MSFT stock in 2011, but I sold it in less than a few years. I learned a few weeks ago, in 2010 $1000 dollar in MSFT stock, the value will be $8,000 dollars. I purchased 10 shares in 2001 December, at that time, I was a home maker and then I worked on my 401 K with Scottrade.com.

Here is the link.

John Bogle, Founder of The Vanguard Group | A Motley Fool Special Interview

Here is the link of one hour interview. I like to watch it again and take some notes.

One fund - balanced fund

2% dividend, 5% growth - if 2% goes to commission, 2% cost to management, what is left?

How many billions of fund goes to index fund?


❉I Knew You Were Trouble -Taylor Swift Victoria's Secret Fashion Show 2013 中文字幕

Here is the link.


How about to practice 8 level hard level algorithms in two days?

Oct. 26, 2019

Introduction


It will be very exciting to see myself to go through struggle to work on 8 hard level algorithms in two days.

What to prepare? 


I like to write down something before I try at least once.


How about to practice 8 level medium level algorithms in two days?

Oct. 26, 2019

Introduction


It is my personal finance research. I have to be ambitious and push myself to increase my value in terms of problem solving. I like to try out two days and try to solve 8 medium level algorithms.

What is possible concerns?


I should prepare what to do in order to improve my experience.

My biggest financial mistake No 1 - $200,000 401 K and IRA gain

Oct. 26, 2019

Introduction


It is my personal finance research. After almost one year financial research, I found out that my biggest financial mistake is how to handle my 401 K and IRA from 1999 to 2019. Twenty years can generate over $200,000 dollars again based on my investment on 401 K from 1999 to 2001, 2004 and 2006 to 2007.

My 401 K contribution


Here is the blog I documented my contributions. I also list in the following:


1999 Atlantic Entertainment   $1880
2000 Atlantic Entertainment   $3610
2000 Trendium                         $650
2001 Trendium                       $5490
2004 IRA deposit                   $3000
2006-2007 Siva, par siva       $8000

Compared to index growth from 1999 to 2019, I do believe that 2010 $1000 on S & P index fund, in 2019 those $1000 dollars investment will be value of $3000 dollars.

I have 20 years to grow those $10,500 dollars from 1999 to 2001. I have 15 years to grow those $3000 dollars starting from 2004, and then I have 12 years to grow those $8000 dollars from 2007.



7 Hacks To Save Money on A Low Income | How To Save Money Fast on a Low Income

Here is the link.


Amazon stock study - Oct. 26, 2019

10月24日,亚马逊公布了2019年第三季财报,营收为699.8亿美元,同比增长24%,但净利润仅为21.34亿美元,较去年同期下滑26%,这也是两年来首度出现季度利润同比下滑。财报一出,这家电商巨头股价在当天盘后一度大挫愈8%,市值蒸发800亿美元。

美国证券交易委员会(SEC)文件显示,贝佐斯持有亚马逊超过5760万股股票,按24日盘后每股近120美元的损失,贝佐斯的身家(Jeff Bezos)在数小时内缩水近70亿美元,也因此在当天将世界首富的宝座拱手相让于比尔盖茨。

据“彭博亿万富翁指数”24日排名统计显示,贝佐斯在全球富豪榜上已位居第二,其净资产跌至1028亿美元,落后于比尔盖茨近50亿美元。不过,25日盘中,亚马逊股价仍微涨1.06%至1780.78美元。

回顾2018年的榜单,彼时的贝佐斯可谓一骑绝尘,个人财富高达1230亿美元。

去年的第三季度财报显示,公司的营收同比增长了29.33%,达到566亿美元,其中超过340亿美元来自北美,净利润高达28.83亿美元,其中亚马逊云服务(AWS)的营收接近70亿美元。

Case study: Word ladder - find all paths

Oct. 26, 2019

Introduction


It was my mock interview at 10:00 PM on Oct. 25, 2019. The interviewee is very experienced engineer, with Google onsite and coming Facebook onsite interview. I like to learn how she wrote the algorithm bug free, and also I like to learn how she trains herself using Leetcode.com. She only solved around 200 algorithms on leetcode.com.

Case study


I like to write the idea using C# as well later. Here is the transcript with the code.



How to work with young engineers?

Oct. 26, 2019

Introduction


It is my dream job to join Amazon or Facebook in 2019, but how can I work with people in my 50s, how to handle the age gap?

Case study


I like to do some short case study by reviewing last 3 mock interviews from Oct. 21 - Oct. 25, 2019.

One thing is to push myself to go for the manager position. Or just stay as an engineer, but with more experience how to handle stress, uncertainty, and rich experience to do better project management.

Let me go back to talk about reality.

I did interview engineers last week. I came cross the top 10 percent engineer who is Ph.D. graduate and work full time. I also met a graduate from top 20 university, with a few years experience working on Uber, and last Friday I met an engineer who went to Google onsite, and prepare Facebook onsite. All three engineers are female, and also work in Silicon Valley.

One thing I learned from them is how to explain their problem solving process, how to calm and analyze clearly.

First eight easy level algorithms - Oct 24 - Oct 25

Oct. 26, 2019

Introduction


It is my personal research how to push myself to advance my problem solving skills. I had some hard time to accept myself, I could tell the weakness, and I know that I was not so patient to my own problems.

First eight easy level algorithms


I like to train myself to work on easy level algorithms. I am always busy and do not spend time to write code; but through those easy level algorithms practice, I can analyze and result shows that I do not plan very well, reading skills, and also need to learn how to explore the problem better.

I include more activities into my practice. I write a post for each practice on Leetcode.com, and also I like to figure out how to motivate myself to work on more algorithms.

Motivations


I like to learn how to motivate myself to learn more through the practice.  I know that hard level algorithm is so important for me to be competitive. How often should I work on learning new algorithms, hard level ones? The problem is that it slows down my performance metrics; I could have solved more algorithms if I choose easy level ones.

Oct. 21 - Oct. 25, 2019
1170. Compare Strings by Frequency of the Smallest Character C# Sort first and then get count of smallest character
985. Sum of Even Numbers After Queries C# Using dynamic programming to track sum of even numbers
1128. Number of Equivalent Domino Pairs C# Learn from three failed test cases
999. Available Captures for Rook C# work on directions and also boundary check carefully
1122. Relative Sort Array C# Good learning experience
509. Fibonacci Number C# optimal time and space complexity
1160. Find Words That Can Be Formed by Characters C# Counting sort technique
1051. Height Checker C# Solve 60 easy level algorithms - No 1 of 60



HULU business case study

Here is the article. 

浅谈视频网站Hulu的成功与失败

人们通常认为射向Hulu的第一颗子弹是由Netflix动手的,这颗子弹的名字叫做《纸牌屋》。与Hulu搬运当下影视内容——这意味着Hulu并不算完全意义上的独家,而且网络播放相比线下仍然存在一定的滞后性——不同的是,北美光碟租售企业Netflix通过数字渠道了解用户的喜好和特征之后,迎合这种需求拿出了自制剧《纸牌屋》,这部剧集在2013年年初横扫美国在线视频市场,同时极为有力的刺激了Netflix的自有业务,使它领跑美国在线影视的销售业绩。
相比“靠天吃饭”的广告,自产自销的模式在性价比和稳定性上更胜一筹,这使Hulu背后的股东坐不住了,而他们又无法理解投资制作一部电影或是电视剧,却根本不将其推到电影院或是电视台内的意义和价值。
然而,早在Netflix和它的《纸牌屋》之前,就有人对Hulu发出过警告:剥离版权,Hulu几乎没有任何剩余资产,Hulu可以是背后数家影视公司的子嗣,但却无法保证自己是独生子嗣,一旦出现更加强势的合作方(例如苹果、亚马逊)加入建立起版权分销市场,Hulu将面临出局的危险。
这个站在“居安思危”立场上的预言最终得到了证实,从2011年开始,Hulu的主要几个大股东(NBC环球集团、新闻集团和迪士尼)不满Hulu单纯的免费影视+广告增值的收入结构,强迫Hulu像Netflix那样推出Hulu Plus收费模式,并且将最高广告时间从2分钟增加到4分钟,希望Hulu能够打造一个旱涝保收的营业壁垒。
但是在互联网上,哪有什么旱涝保收的生意在呢?

HULU

I like to study business, one of ideas is to read more about HULU. Here is the article.


相比Youtube的名声,Hulu在中国的曝光度并不高,毕竟,UGC更容易制造传播上的热点,在用户带宽尚处起步阶段的时期,人们也易于接受画质模糊但内容有趣的短视频。但是Youtube始终没能建立起成功的盈利模式,它的存活,完全仰仗于Google在2006年掏出16.5亿美元买下了它,然后成为Google战略部署中的一枚棋子。也正是为了对抗网络视频对于传统影视行业的侵蚀、将用户的注意力从搞笑的猫咪身上拉回制片商耗费巨资拍摄出来的影视大片身上,NBC环球集团和新闻集团出资在2007年出资成立了Hulu,并且拉来了亚马逊CEO杰夫·贝索斯的得力干将杰森·吉拉尔担任CEO。 [2] 
中国大陆已于2010年12月8日禁止解析Hulu网站,将其屏蔽。

硅谷妈妈诸葛越:人工智能颠覆职场,如何培养适应未来的孩子?

Here is the link.


诸葛越2018爱奇艺世界大会演讲开场

Here is the link.


Hulu全球副总裁诸葛越:女性如何做技术团队老大?



Introduction


It is a small world. I spent a lot of time to cultivate the wechat group of 1984 to 1988 Shanghai Jiaotong university, I like to ask questions and share my blog, motivate people think and ask questions. Today I got invited to connect to one of alumni, and he shared with me his wife's wechat public account. I googled her name since she has computer science Ph.D. degree from Stanford university.

Stanford computer science Ph.D.

Here is the article.
所以今天我主要是讲技术管理,因为我现在管的是一群高智商的技术人员,也有很多是男生,技术行业里面确实女生比较少。我稍微讲一下作为一个技术管理者,我一般每天都在做什么,这是一个很大的命题。最后会稍微讲一下女性在做技术高管时,怎样才能够做得比较好,主要是讲这三点。
作为技术管理者,职责简单的说就是三个,招人,管人和他们的成长。

Friday, October 25, 2019

The One Habit That Will Keep You Poor Forever | How To Be Good With Your Money

Here is the link.


The #1 Way To Become Rich | How To Become Rich in 5 Years

Here is the link.


1128. Number of Equivalent Domino Pairs

Here is the link.

C# Learn from three failed test cases

Oct. 25, 2019
It is such good practice to write a solution with rich learning experience. My reading skills can not catch up since I missed three test cases.
Case study
I failed three test cases.
  1. [[1,2],[1,2],[1,1],[1,2],[2,2]] should be 3, not 0
  2. [[1,2],[1,2],[1,1],[1,2],[2,2]] should be 3, not 2
  3. [[1,1],[2,2],[1,1],[1,2],[1,2],[1,1]] should be 4, not 7
I learned from the first test case, and then I decided to keep the count of key. I design to use integer 10 * i + j to represent a pair with integer [i, j].
I chose to write using HashSet, since count of key has to be saved, so I just choose to use an integer array, using index value as key, value as count of key.
I spent over 10 minutes to write the first submission, and then 2 minutes to fix failed test case 1, and then another three minutes to fix failed test case 2, and then another two minutes to failed test case 3.
The following is my C# code passing all test cases.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

        /// <summary>
        /// Oct. 25, 2019
        /// 1128. Number of Equivalent Domino Pairs
        /// Failed test case:
        /// 1. [[1,2],[1,2],[1,1],[1,2],[2,2]] should be 3, not 0
        /// 2. [[1,2],[1,2],[1,1],[1,2],[2,2]] should be 3, not 2
        /// 3. [[1,1],[2,2],[1,1],[1,2],[1,2],[1,1]] should be 4, not 7
        /// 
        /// </summary>
        /// <param name="dominoes"></param>
        /// <returns></returns>
        public int NumEquivDominoPairs(int[][] dominoes)
        {
            var rows = dominoes.Length;

            var keyCount = new int[100];

            int count = 0;
            for (int i = 0; i < rows; i++)
            {
                var first = dominoes[i][0];
                var second = dominoes[i][1];

                var reversedKey = second * 10 + first;
                var key = first * 10 + second;

                count += keyCount[key];

                if (key != reversedKey)
                {
                    count += keyCount[reversedKey];
                }

                keyCount[key]++;
            }

            return count;
        }
    }
}


7 Things You Must GIVE UP To Be Rich | How To Be Rich For Beginners

Here is the link.


#1 Mistake Poor People Make | How To Be Good With Your Money

Here is the link.


Don't Spend Any Money Before Doing This | How To Be Good With Your Money

Here is the link.


8 easy level algorithm practice in 2 days

Oct. 25, 2019

Introduction


It is my small research to see how many easy level algorithms I can solve in 2 days. What is my experience to solve those algorithms? I like to write a blog to document the experience.

Case study


I just turned 53 years old in October 2019. In 2018 I solved over 100 easy level algorithm after August, and then solved some medium level algorithms as well. I started on Oct. 24, 2019, and in two days I solved 8 algorithms.


Based on the above 8 easy level array algorithms, I still have problems in my design and choice of writing the code, I took the risk and then ran into time limit exceeded bug. In other words, I took the risk and I did not try to aim best time complexity in the first time.

Second is about the algorithm, Number of equivalent domino pairs, I had to try 4 times to fail three test cases; in other words, I did not think ahead all possible edge cases. I still relied on Leetcode online judge.

I take too many breaks. How come I only can solve less than five algorithm in a day?

My next assignment


I like to write those 8 algorithms using JavaScript.


7 Expensive Habits That Will Keep You Poor | How To Be Good With Your Money

Here is the link.

1. dopamine high - open wallet to spend
    Need to fit in ...
    Management of money - the rich use this money
2. Sacrifice future rewards for present pleasure

Delaying gratification -> delay discounting -> future payoffs -> present awards






7 Habits Rich People Have That You Don't | Habits Of The Rich

Here is the link.

Lifestyle creep - $100,000 dollars sports car, if there is a raise or something similar.


How to retire at age 40? 401 K

充分利用4O1K,分阶段覆盖财务支出

一般来说美国人退休收入主要来源有以下几种:

1.Social Security——类似我国的统筹账户。
2.各种个人账户的法定分配——类似我国的商业养老保险。
3.个别政府/学校/机构的养老金——类似我们父母那一代人退休后拿的“退休金”。

其中第3条是个小概率事件,绝大多数企业都没有。第1条最好不用指望,Social Security账户已经入不敷出N年了,所以真正的大头是第2条。

美国人进入公司后,都会获得公司提供的福利计划,这其中的大头就是401K。这东西说白了其实就是一个共同基金,不过在共同基金的本质上,美国国税局给你提供了有别于一般共同基金的“税收安排”。如果在投资和持有401K账户的期间内,里面的资金每年都不用交资本利得税。但是在59岁半之前,这个账户里的钱,你不能取出来,否则要交资本利得税和额外10%的惩罚税。当然美国国税局给这种的税收安排好处,不能无限制享受,每年只能在一定的限额内享受。在刚过去的2019年,这个限额是每年19,000刀。

注意401K不需要缴惩罚税的年龄段是59岁半,这就意味着59岁之后的退休生活中,有相对一部分支出可以交由401K来覆盖掉。