Wednesday, October 3, 2018

America retirement and benefit study

Oct. 3, 2018

Introduction


I came cross the article in Chinese. Here is the link. I like to copy and paste to my own blog, I need to do some research as well.

USA retirement 

美国现在每天有一万人退休,上世纪80-90年代大陆来的第一代留学生也渐渐进入退休年龄,在为退休生活做准备。在做退休财务规划时,有几个关键的年龄需要记住,很多与退休有关的法律和规定都与这几个年龄有关。
年满50岁如果你今年满50岁,又有工作收入 (earned income), 你投入401K、403B的钱可以再加$5500, 2014年的上限是$23,000; 如果是 IRA或Roth IRA, 则可以加$1000, 最多可以放$6500. 不论是从增加日后的退休基金还是从省税的角度,都因好好利用这一规定。如果你每年往401K多放$5500, 15年到65岁就是8万多,再加上可能的上涨,8万多变成10万以上都是有可能的。这多出来的10万或十几万对你的退休生活不无小补。
此外,如果你配偶过世,你又伤残(disable), 满了50岁你可以开始申领social security的未亡人伤残福利, 这种福利一般是过世配偶全额退休福利的71.5%.

年满
55岁:年满55岁又离职了,可以从group-sponsored 的退休计划拿钱而没有10%的罚款,这种退休计划包括Defined Benefit Plan 和Keogh等,但不包括IRA。

年满
59岁半:这可能是IRS规定的最重要的年龄、也是最为人所欢迎的年龄,一旦你满了59岁半,你从退休计划中拿钱不用交10%的罚款。这种免交10%罚款的规定适用于任何退休计划,不论是qualified 的退休计划如401k, IRA,还是non-qualified年金,只要你达到59岁半这一神奇的年龄,就可享受免交10%罚款的政策规定。

年满
60岁:丧偶的年满60岁可以开始领取social security的遗属福利,一般是过世配偶全额退休福利的71.5%.

年满
62岁:这是靠 Social security过活的大部分美国人盼星星盼月亮的年龄,只要你满了62岁,你就可以申领social security的退休福利。当然62岁就开始领,只能领到部分福利(partial benefit), 相当于full benefit的75%。如果你不是吃了上顿没下顿,一般建议是延缓申领退休福利,因为每推迟一年,你的退休福利大概多8%,到了70岁你的退休福利不再增加。当然什么时候开始领退休福利,除了财务因素外,还要考虑健康因素。如果你身体不好,甚至百病缠身,则应考虑早点领取social security的退休福利,原因很简单,social security没有收益人。如果你健康长寿,获到100岁,你领的social security福利可能远远大于你交的税;而如果你刚领没几年就驾鹤西归了,又没有未成年子女,你交的social security tax就归Uncle Sam 了,用来给其他人发放福利.

年满
65岁:可以开始Medicare,包括看医生、住院、拿药等各种保险福利,但不包括因生活不能自理而需要住到nursing home,或请人到府照顾的花费,这种花费通常要通过购买长期护理保险来cover。

年满
67岁:1960年以后出生的人,必须年满67岁才可以申领social security 的全额退休福利。每晚一年开始拿,退休福利多8%左右,直到70岁,退休福利不再自动增加,最多随通货膨胀率每年加一点。

年满
70岁半 前文说过年满59岁半可以开始从退休计划中拿钱而无需交10%的罚款,当然你也可以不拿钱,直到70岁半,这时你就必须开始往外拿钱,IRS术语叫RMD (required minimum distribution)。这个RMD每年增加,71岁是26.5, 75岁是22.9,80岁是18.7, 90岁是11.4, 100岁是6.3. 举例说,你今年满71岁,你退休计划各个账户有100万,100万除以26.5,你这一年必须拿$37,735.85;如果你满75岁,依然是100万,除以22.9,你这一年必须拿$43,668.12. 也就是说你每大一岁,你从退休账户拿的RMD百分比要多一点。算法是以你账户上一年12月31日的总额来计算。你2014年拿RMD,是以2013年12月31日你退休计划的总金额,再除以你年龄的RMD比率。如果你不拿钱,或没有拿够RMD的话,你可能会有50%的罚款。IRS这么做,主要是为了征税,因为你不从退休计划里拿钱,IRS就征不到税。如果你满了70岁半,你开户的银行或金融机构都会给你寄表格,问你要拿多少,你可以多拿,但不可以少拿。你有10个帐号,可以只从一个帐号拿钱,但要拿够所有10个帐号总额的RMD. 如果不拿或没有拿够RMD, 国税局会有50%的罚款,够狠的!举例税,你当时各种退休账户上有100万,根据RMD你应该拿3万7,但你只拿了3万,那未拿的7千你下一年不仅要补拿,IRS可能还会罚你3500,够狠的.

有两种退休计划账户不用拿
RMD, 一是Roth IRA, 二是各种non-qualified 退休计划。Roth IRA 大家都知道,而non-qualified 退休计划主要是指用税后的钱买的各种年金(annuity).年金最大的好处是延税(tax deferral), 只要不拿出来,就不用交税,拿出来时再交税。你可以拿税前的钱去买年金,如IRA 或401K Rollover, 如果是用税前的钱买的年金,到了70岁半,你也要开始拿RMD。但如果是用税后的钱买的年金则不受RMD的约束,可以一直不拿钱。除了延税外, 年金的另外一个主要好处是可以提供终身收入保障,你有生之年保险公司都保证每年给你一个固定收入,不受股市起伏的影响。在人的寿命越来越长的今天,购买这 种有终身收入保障的年金也是退休计划的重要组成部分。

Leetcode 37 Sudoku solver

Oct. 3, 2018

Introduction


It is time for me to review all my past practice on medium and hard level hashtable tagged algorithms. I wrote a C# solution based on my past submissions, and then I shared on Leetcode discuss.

My practice


Here is my discuss link.

It is so much fun to read the code I submitted from 2015 to 2018. Through every submissions, I am so glad to learn that I am much more confident programmer and code is much more efficient.

Here is my github folder to look up all my submissions through Leetcode.

Let me get my submission history image here. It is so much fun to read the log.



Review medium and hard level hashtable algorithm

Oct. 3, 2018

Introduction


It is a good idea to share all my practice on Leetcode discuss, medium level and hard level.

Algorithms to review


I solved 4 hard level, 6 medium level algorithm.

Medium level

    3   longest substring without repeating characters
  18   4 sum
  49   Group anagrams
  94   Binary tree inorder traversal
187   Repeated DNA sequences
347   Top k frequent elements
554   Brick wall

Hard level

  37   Sudoku Solver
  76   Minimum window substring
  85   Maximal rectangle
726   Number of atoms

Actionable Items


I reviewed the algorithm 726 Number of atoms. It is so complicated. I think that I should spend time to work on easy level and medium level algorithms first. 

I shared my C# code of Leetcode 37 Sudoku solver, here is discuss link. 



350. Intersection of Two Arrays II

Hashtable easy level algorithm
136. Single Number using XOR
242. Valid Anagram One more mistake to remind me to work on easy level
350. Intersection of Two Arrays II
389. Find the Difference using XOR
409. Longest Palindrome 
447. Number of Boomerangs
463. Island Perimeter 
500. Keyboard Row do it myself
500. Keyboard Row use HashSet API IsSubsetOf
575. Distribute Candies Need to work on my reading skills
599. Minimum Index Sum of Two Lists
706. Design HashMap Use fix size of space determined by upper bound
720. Longest Word in Dictionary use hashset
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Queue data structure
720. Longest Word in Dictionary use recursive function

Learn from my mock interview experience

Oct. 3, 2018

Introduction


It is very helpful for me to evaluate the candidates in the market and also I like to learn how to stay humble, work hard. I have a role model who works for Facebook, and then I compare my practice with him.

I meet people, and most of time people tell me that he finished over 200 algorithms in 3 months.

I learn to evaluate a candidate with 250 Leetcode algorithms in three months. After the mock interview, he advised me to work on practice as he does. He worked on first 250 Leetcode algorithms. But he chose to work on the same type algorithm together. For example, dynamic programming, he worked on all dynamic programming from easy, medium and hard level together, and then he moved on to work on other type of algorithms. Categories of algorithm can be dynamic programming, tree, array, math, string, stack, heap.



Comparison


I spent over three years to work on 100 Leetcode algorithms. Compared to the one using three months, 250 Leetcode algorithms, 160 lintcode algorithms.

Last three month, I worked on 140 easy level algorithms.

I need to work hard to solve more problems. I have to get good habit to read and think and write code.

Longest univalue path algorithm


It is challenging for me to be an interviewer, for my favorite easy level tree algorithm. I know that the algorithm should be marked as difficult.

I worked with the peer, and then peer asked me for a hint. So I gave the following hint:

Tree with one node value 5,

  5

please return 0


Tree with root node value 5, and left child 5 and right child 1, please return 1

  5
 / \
5   1


Tree with root node value 5, and left child 5 and right child 5, please return 2

  5
 /  \
5   5

The interviewee took hint quickly and wrote a perfect answer in 10 minutes.


706. Design HashMap

Hashtable easy level algorithm
136. Single Number using XOR
242. Valid Anagram One more mistake to remind me to work on easy level
350. Intersection of Two Arrays II
389. Find the Difference using XOR
409. Longest Palindrome 
447. Number of Boomerangs
463. Island Perimeter 
500. Keyboard Row do it myself
500. Keyboard Row use HashSet API IsSubsetOf
575. Distribute Candies Need to work on my reading skills
599. Minimum Index Sum of Two Lists
706. Design HashMap Use fix size of space determined by upper bound
720. Longest Word in Dictionary use hashset
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Queue data structure
720. Longest Word in Dictionary use recursive function

599. Minimum Index Sum of Two Lists

Hashtable easy level algorithm
136. Single Number using XOR
242. Valid Anagram One more mistake to remind me to work on easy level
350. Intersection of Two Arrays II
389. Find the Difference using XOR
409. Longest Palindrome 
447. Number of Boomerangs
463. Island Perimeter 
500. Keyboard Row do it myself
500. Keyboard Row use HashSet API IsSubsetOf
575. Distribute Candies Need to work on my reading skills
599. Minimum Index Sum of Two Lists
706. Design HashMap Use fix size of space determined by upper bound
720. Longest Word in Dictionary use hashset
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Queue data structure
720. Longest Word in Dictionary use recursive function

409. Longest Palindrome

Hashtable easy level algorithm
136. Single Number using XOR
242. Valid Anagram One more mistake to remind me to work on easy level
350. Intersection of Two Arrays II
389. Find the Difference using XOR
409. Longest Palindrome 
447. Number of Boomerangs
463. Island Perimeter 
500. Keyboard Row do it myself
500. Keyboard Row use HashSet API IsSubsetOf
575. Distribute Candies Need to work on my reading skills
599. Minimum Index Sum of Two Lists
706. Design HashMap Use fix size of space determined by upper bound
720. Longest Word in Dictionary use hashset
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Queue data structure
720. Longest Word in Dictionary use recursive function

447. Number of Boomerangs

Hashtable easy level algorithm
136. Single Number using XOR
242. Valid Anagram One more mistake to remind me to work on easy level
350. Intersection of Two Arrays II
389. Find the Difference using XOR
409. Longest Palindrome 
447. Number of Boomerangs
463. Island Perimeter 
500. Keyboard Row do it myself
500. Keyboard Row use HashSet API IsSubsetOf
575. Distribute Candies Need to work on my reading skills
599. Minimum Index Sum of Two Lists
706. Design HashMap Use fix size of space determined by upper bound
720. Longest Word in Dictionary use hashset
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Queue data structure
720. Longest Word in Dictionary use recursive function

242. Valid Anagram

Hashtable easy level algorithm
136. Single Number using XOR
242. Valid Anagram One more mistake to remind me to work on easy level
350. Intersection of Two Arrays II
389. Find the Difference using XOR
409. Longest Palindrome 
447. Number of Boomerangs
463. Island Perimeter 
500. Keyboard Row do it myself
500. Keyboard Row use HashSet API IsSubsetOf
575. Distribute Candies Need to work on my reading skills
599. Minimum Index Sum of Two Lists
706. Design HashMap Use fix size of space determined by upper bound
720. Longest Word in Dictionary use hashset
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Queue data structure
720. Longest Word in Dictionary use recursive function

389. Find the Difference

Hashtable easy level algorithm
136. Single Number using XOR
242. Valid Anagram One more mistake to remind me to work on easy level
350. Intersection of Two Arrays II
389. Find the Difference using XOR
409. Longest Palindrome 
447. Number of Boomerangs
463. Island Perimeter 
500. Keyboard Row do it myself
500. Keyboard Row use HashSet API IsSubsetOf
575. Distribute Candies Need to work on my reading skills
599. Minimum Index Sum of Two Lists
706. Design HashMap Use fix size of space determined by upper bound
720. Longest Word in Dictionary use hashset
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Queue data structure
720. Longest Word in Dictionary use recursive function

136. Single Number

Hashtable easy level algorithm
136. Single Number using XOR
242. Valid Anagram One more mistake to remind me to work on easy level
350. Intersection of Two Arrays II
389. Find the Difference using XOR
409. Longest Palindrome 
447. Number of Boomerangs
463. Island Perimeter 
500. Keyboard Row do it myself
500. Keyboard Row use HashSet API IsSubsetOf
575. Distribute Candies Need to work on my reading skills
599. Minimum Index Sum of Two Lists
706. Design HashMap Use fix size of space determined by upper bound
720. Longest Word in Dictionary use hashset
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Queue data structure
720. Longest Word in Dictionary use recursive function

575. Distribute Candies

Hashtable easy level algorithm
136. Single Number using XOR
242. Valid Anagram One more mistake to remind me to work on easy level
350. Intersection of Two Arrays II
389. Find the Difference using XOR
409. Longest Palindrome 
447. Number of Boomerangs
463. Island Perimeter 
500. Keyboard Row do it myself
500. Keyboard Row use HashSet API IsSubsetOf
575. Distribute Candies Need to work on my reading skills
599. Minimum Index Sum of Two Lists
706. Design HashMap Use fix size of space determined by upper bound
720. Longest Word in Dictionary use hashset
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Queue data structure
720. Longest Word in Dictionary use recursive function

Tuesday, October 2, 2018

463. Island Perimeter

Hashtable easy level algorithm
136. Single Number using XOR
242. Valid Anagram One more mistake to remind me to work on easy level
350. Intersection of Two Arrays II
389. Find the Difference using XOR
409. Longest Palindrome 
447. Number of Boomerangs
463. Island Perimeter 
500. Keyboard Row do it myself
500. Keyboard Row use HashSet API IsSubsetOf
575. Distribute Candies Need to work on my reading skills
599. Minimum Index Sum of Two Lists
706. Design HashMap Use fix size of space determined by upper bound
720. Longest Word in Dictionary use hashset
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Queue data structure
720. Longest Word in Dictionary use recursive function

500. Keyboard Row

Hashtable easy level algorithm
136. Single Number using XOR
242. Valid Anagram One more mistake to remind me to work on easy level
350. Intersection of Two Arrays II
389. Find the Difference using XOR
409. Longest Palindrome 
447. Number of Boomerangs
463. Island Perimeter 
500. Keyboard Row do it myself
500. Keyboard Row use HashSet API IsSubsetOf
575. Distribute Candies Need to work on my reading skills
599. Minimum Index Sum of Two Lists
706. Design HashMap Use fix size of space determined by upper bound
720. Longest Word in Dictionary use hashset
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Queue data structure
720. Longest Word in Dictionary use recursive function

500. Keyboard Row

Hashtable easy level algorithm
136. Single Number using XOR
242. Valid Anagram One more mistake to remind me to work on easy level
350. Intersection of Two Arrays II
389. Find the Difference using XOR
409. Longest Palindrome 
447. Number of Boomerangs
463. Island Perimeter 
500. Keyboard Row do it myself
500. Keyboard Row use HashSet API IsSubsetOf
575. Distribute Candies Need to work on my reading skills
599. Minimum Index Sum of Two Lists
706. Design HashMap Use fix size of space determined by upper bound
720. Longest Word in Dictionary use hashset
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Trie data structure
720. Longest Word in Dictionary use Queue data structure
720. Longest Word in Dictionary use recursive function

Having a role model

Oct. 2, 2018

Introduction


It is time for me to learn something from a role model. I like to study those players who have solved over 500 Leetcode algorithms.

Today the role model is Yuan Li, who happened to be a facebook engineer. The profile is here.

I usually do not know how to learn from the role model. I just quickly go over the linkedin profile, and then try to look into some detail.

Get some data


Honorable mention in ACM/ICPC World Final in St. Petersburg, Russia

honor dateJul 2013

4th place in the 36th ACM/ICPC North America Regional Contest

honor dateNov 2011



      

What I like to do is to compare how quickly a person can learn. After three months, I like to see what is difference.

I only solve 246 algorithms, compare to 799 algorithms. My global ranking of contest is 12026 compared to 5. I only played around 6 weekly contest.

Best way to join the community of Leetcode



I think that it is so important for me to learn how the community works around Leetcode. I could not believe that I did not find Leetcode discuss product feature from January to December 2015. I always searched Google and find some blogs written in Chinese.

It is the first time I learn how to get involved in the community until this July 2018. I decided to work on easy level algorithms, and also I like to learn better way to learn and stay organized.

I did play a few Leetcode weekly contest in 2017, but I stopped. I documented my practice of the algorithm in my blog in 2018, but better way is to share with Leetcode community thousands of players, and also contribute the idea.

Sometimes great ideas can be found through the discuss, and sometimes through mock interview I got a peer sharing their experience from Leetcode.com.

I also learn to read my own data on Leetcode community. Make judgement based on data from Leetcode.com. I should respect all other players as well. If I am not competitive enough, it will definitely show up how many algorithms I solve, how many contests I play, and what is my global ranking of contest.

Also my personality will also show up in my sharing on those easy level algorithms. How open I write my practice, sharing of my failure, mistakes, story about the training, ideas to improve etc.

45 days players can finish 200 to 400 algorithms. For those top university top ranking computer science graduate students, some of them can really get very aggressive learning through the community.

I need to get more aggresive, since last 3 months I solved 150 easy level algorithms. Next three months, I like to solve 200 medium level algorithms.

Monday, October 1, 2018

How to solve over 400 algorithms in 45 days?

Oct. 1, 2018

Introduction


It is 10:32 PM. I like to work on a short research called how to solve over 400 algorithms in 45 days. I met a young graduate student over one month ago, he told me that he finished over 400 algorithm in 45 days, and over 250 algorithms are medium level.

Just be creative 


I like to write down 10 ideas how to make submission of 400 algorithms in 45 days.

1. Work on easy level algorithms first.
2. Learn how to solve 10 algorithm a day.
3. If I cannot do item 2, try to work on 10 submissions a day.
4. If I cannot do item 3, then I should be able to read 10 solutions, and write C# code based on those most popular discuss first.
5. If I cannot do item 4, I may ...

How to take short breaks?

Oct. 1, 2018

Introduction


It is 10:16 PM, how to take short breaks while working on Leetcode easy level algorithms. I wish that I can work 10 easy level algorithm without a break.

Here is the story. I solved 4 easy level hashtable algorithm, but I could not come out the solution for the fifth one. I read the problem statement over three times, I read a few solutions, and then I finally understood the problem. But I felt tired. I took a break 1 hour 19 minutes.

I need to do some research and figure out how to delay the break.

Get data first


Here is my submissions and then I took a break. Now it is 11:22 PM, Oct. 1, 2018.


I worked on problem solving just over one hour, and then I felt tired.

Reading skills

Oct. 1, 2018

Introduction


I like to write a blog about reading skills and how it relates to algorithm and data structure problem solving. I had some hard time to figure out the problem requirement on hashtable easy level algorithm. I read problem statement more than three times, and also it took me more than 10 minutes.

It is Leetcode 575 Distribute candies.