Oct. 3, 2018
Introduction
It is time for me to say goodbye to easy level hashtable algorithms. I do need to spend time to review my practice, read more discuss, and improve myself. Most of important is to get organized, share all practice on Leetcode discuss first.
Leetcode discuss
Here is the algorithms I shared on Leetcode discuss.
Hashtable easy level algorithm (solved 25, shared 21)
1. Two Sum
136. Single Number using XOR (1 upvote)
204. Count Primes verbose code
204. Count Primes elegant version
205. Isomorphic Strings
219. Contains Duplicate II
242. Valid Anagram One more mistake to remind me to work on easy level
290. Word Pattern
350. Intersection of Two Arrays II
389. Find the Difference using XOR
409. Longest Palindrome
438. Find All Anagrams in a String
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
594. Longest Harmonious Subsequence
599. Minimum Index Sum of Two Lists
645. Set Mismatch first submission - XOR
645. Set Mismatch elegant one using XOR two places
645. Set Mismatch use bit manipulation trick
705. Design HashSet
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
From January 2015, she started to practice leetcode questions; she trains herself to stay focus, develops "muscle" memory when she practices those questions one by one. 2015年初, Julia开始参与做Leetcode, 开通自己第一个博客. 刷Leet code的题目, 她看了很多的代码, 每个人那学一点, 也开通Github, 发表自己的代码, 尝试写自己的一些体会. She learns from her favorite sports – tennis, 10,000 serves practice builds up good memory for a great serve. Just keep going. Hard work beats talent when talent fails to work hard.
Wednesday, October 3, 2018
Hard level algorithm and feelings
Oct. 3, 2018
I choose to work on easy level algorithms since this July 2018. I never feel so relax and enjoyable last three months.
Today I had chance to review some of hard level algorithms. I learn that the algorithm can get so complicated. I better learn one thing a time for multiple easy level algorithms.
It can make big difference to choose good strategy to practice Leetcode algorithms.
Introduction
I choose to work on easy level algorithms since this July 2018. I never feel so relax and enjoyable last three months.
Today I had chance to review some of hard level algorithms. I learn that the algorithm can get so complicated. I better learn one thing a time for multiple easy level algorithms.
Get smart on learning
726. Number of Atoms
Oct. 3, 2018
I wrote a post on leetcode discuss and shared my C# code submitted in 2017.
Here is my summary of practice.
Here is the discuss link.
Introduction
I wrote a post on leetcode discuss and shared my C# code submitted in 2017.
My post
Here is my summary of practice.
It is a hard level algorithm. I practiced the algorithm in February 2018. I did study at least 4 ideas, and then submitted one solution.
Here are the five blogs related to my study of the hard level algorithm.
- http://juliachencoding.blogspot.com/2018/01/leetcode-726-number-of-atoms.html
- http://juliachencoding.blogspot.com/2018/01/leetcode-726-number-of-atoms-ii.html
- http://juliachencoding.blogspot.com/2018/02/leetcode-726-number-of-atoms-iii.html
- http://juliachencoding.blogspot.com/2018/02/leetcode-726-number-of-atoms-iv.html
- http://juliachencoding.blogspot.com/2018/02/leetcode-726-number-of-atoms-v.html
I think that it is better to work on easy level or medium level algorithm first.
I like to share my C# code first.
Here is the discuss link.
85. Maximal Rectangle
Oct. 3, 2018
It is a hard level algorithm. I plan to review the algorithm and read more discuss on Leetcode.com first.
Here is my discuss link.
Introduction
It is a hard level algorithm. I plan to review the algorithm and read more discuss on Leetcode.com first.
My practice
Here is my discuss link.
America retirement and benefit study
Oct. 3, 2018
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.
年满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的约束,可以一直不拿钱。除了延税外, 年金的另外一个主要好处是可以提供终身收入保障,你有生之年保险公司都保证每年给你一个固定收入,不受股市起伏的影响。在人的寿命越来越长的今天,购买这 种有终身收入保障的年金也是退休计划的重要组成部分。
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
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.
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.
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
It is a good idea to share all my practice on Leetcode discuss, medium level and hard level.
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
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.
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
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
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.
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.
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.
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
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
Subscribe to:
Posts (Atom)
