Thursday, November 24, 2016

Stack Exchange: Code Review - Julia's new school

Nov. 24, 2016

Julia started her first day to look into stack exchange: code review, and then, she joined one of discussion - quicksort, she was amazed how she learned quickly in the place.

Her first reading starts from here:

http://codereview.stackexchange.com/questions/5648/any-way-to-make-this-recursive-function-better-faster/5661?newreg=7b2fea2453a54c15bc466355fea0891d

Learn from expert on code review:

http://codereview.stackexchange.com/questions/142808/quick-sort-algorithm/142853#142853

http://codereview.stackexchange.com/a/142853/123986

Julia also wrote a blog about quick sort in 2016:

http://juliachencoding.blogspot.ca/2016/02/quick-sort-practice-makes-difference.html

Julia's favorite reading:
 http://codereview.stackexchange.com/questions/77782/quick-sort-implementation?rq=1

Study stackoverflow profile:
http://codereview.stackexchange.com/users/507/loki-astari

Actionable Items:

Read more live discussion on stackoverflow code review sections, at least find 5 top talents in C++, and find 10 advises from them in a week.

1. First one: Loki astari

Study stackoverflow profile:
http://codereview.stackexchange.com/users/507/loki-astari

Julia's favorite learning on Nov. 25, 2016:

-- start learning: 

http://codereview.stackexchange.com/a/77821/123986

 - 

Compilers Job

Don't do work the compiler can do for you:
int arr[8] = {110, 5, 10,3 ,22, 100, 1, 23};
The compiler is better than you at it anyway and it will prevent errors. Here you have said the number of elements is 8. As a human I can't see that at a glance I could count them to verify but as a human I am lazy and going to assume you got it correct. If you did not get it correct then we will have problems.
So let the compiler work it out.
int arr[] = {110, 5, 10,3 ,22, 100, 1, 23};
Now if the array changes size you only have to change one thing (the data). Rather than two things (data and size).
 -- end of learning  --

Coding Style - Great advice on coding/ design, a hackerRank question:

http://codereview.stackexchange.com/questions/140825/keeping-track-of-the-tennis-score/140827#140827

Book reading: Java Puzzles

Nov. 24, 2016

Here is C# reading list:

http://www.informit.com/articles/article.aspx?p=1769249

One of books is Julia's new favorite, she read first 3 puzzles, she loves them. So, she starts to read the book one puzzle at a time.

Java Puzzlers by Joshua Bloch and Neal Gafter


More reading:

http://codereview.stackexchange.com/questions/5648/any-way-to-make-this-recursive-function-better-faster/5661?newreg=7b2fea2453a54c15bc466355fea0891d


Leetcode 300: longest increasing subsequence

Nov. 24, 2016

Motivated by the article reading:
https://blogs.msdn.microsoft.com/ericlippert/2004/07/21/recursion-and-dynamic-programming/

Julia likes to practice this Leetcode 300, and then look into various solution using dynamic programming.

First, write a C# program using recursive, memorization solution, using code in the above blog.




HackerRank - woman codesprint#2 stone division - recursive design study (series 5 of 5)

Nov. 24, 2016

Being a software programmer, Julia learned the lesson through this medium algorithm - stone division; she stumbled on it, struggled to make it work over 5 hours, she knew that she had to make changes.  

She likes to do some research on recursive common mistakes, and then, further topic on recursive design concerns. After a few hours study based on Google search "recursive common mistakes", she felt that the study is still too weak. She likes to find some one with very strong technical background in industry, share ideas. So, with her research on stackoverflow recently, she started to look into who made contribution on stackoverflow on this topic. She found a lot to read. 

Here is her research to find her something to read on this topic: 

stackoverflow->
http://stackoverflow.com/questions/25676961/understanding-how-recursive-functions-work?noredirect=1&lq=1
->
http://stackoverflow.com/users/88656/eric-lippert  (People reached: 10.8 million)
-> 

She found a top programmer, who designed C# in Microsoft and then work for facebook, and also she found the first article so helpful. 

Julia likes the style of writing and she quickly identified that the article has a great teaching style.  

https://blogs.msdn.microsoft.com/ericlippert/2004/07/21/recursion-and-dynamic-programming/

(Compared to Julia's sharing, two articles: first, she worked on leetcode algorithm, Leetcode 300: longest common subsequence, she blogged about it. second, she wrote on the dynamic programming, Lintcode 79: longest common substring, she also worked on it in 2016. )

Recursion series, more reading:

Julia's notes: 

Part 0:

Part 1: 
Teach how to think about recursion 

recursive way to think about a list emphasizes the similarity of a fragment of the list to the whole list. 
recursively define a list as either
1. the empty list with zero items on it, or
2. an item followed by a list

appear to be a circular definition, but it is really not. 'Spiral' definition

All recursive functions follow the same basic pattern: 
Am I in the base case? If so, return the easy solution. 
Otherwise, figure out some way to make the problem closer to the base case and solve that problem. 

bottom out - base case 

A binary tree is either:
an empty tree, or 
a value associated with two binary search trees, called the left and right child trees. 

inductive hypothesis - 

Part two: unrolling a recursive function with an explicit stack 

1 million nodes - balanced tree - 20 recursive depth - 2^10 = 1024, so 1 million is around 2^20

"anonymous locals" - 

callee's frame   -  caller's frame  - current activation frame 

the temporary variables are spelled out 
each recursion happens on its own line

Part three: build a dispatch engine

January 13, 2017
Julia worked hard on the blog study, and then, she found out the code review on stackexchange.com, and then she started to post questions on algorithms, and get connected to the community. And this is a break-through, finally Julia stepped out her lonely zone - blogging, practicing, contest, and get really connected to people with same spirit - volunteer and also community builders. 


Feb. 23, 2017
Read the article about Google interview, and then read the comment from an ex-googler: 

With all that said, I haven't found any degree (at least from any school I've interviewed applicants for) to be a reliable signal for programming. Even if they went to a really good school, there's a good chance that they spent all their time learning network protocols and low-level mechanisms, and will happily write up a sliding-window implementation for me, but will stare at me blankly when I ask for a simple recursive algorithm. It's just tough to find people that spent time studying and practicing general-purpose computer science.

So, Julia reviewed the algorithm and wrote a more readable C# version to post a question on stackexchange.com. 

Wednesday, November 23, 2016

HackerRank - Woman codesprint#2 stone division - recursive intensive training (series 3 of 5)

Nov. 23, 2016

Julia failed on one medium algorithm - recursive function in the contest. So, she likes to get some training on the skill. 

 A few reasons she failed:
 1. Extra work - Recursive function involves building a string first. 
 2. Time consuming   - use StringBuilder, backtracking
 3. Failed to pass second test case; idea is not correct. 

Previous work intensive on recursive function:


Last time Julia learned recursive work intensively through HackerRank Linked List:

started from May 8 to , over 10 blogs about linked list:
http://juliachencoding.blogspot.ca/2016/05/hackerrank-linked-list-find-merge-point.html

http://juliachencoding.blogspot.ca/2016/05/hackerrank-insert-node-in-double-linked.html

Julia just marked all 13 linked list practice with label: linked list.

Use linked list in blog search to find all 13 of them.


Tuesday, November 22, 2016

UVa online judge and a solution blog

Nov. 22, 2016

Plan to work on the UVa online judge and read the solution blog, and see if Julia enjoys the solution. 

Blog reading:
UVa website
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=36

Solution website: facebook tool engineer - ICPC winner in 2011 - 2012
http://www.questtosolve.com/browse.php

A few notes about how to start this blog with all solutions:

Julia worked on the HackerRank, and then, she followed one of player on twitter less than a week ago, who has an experience on ACM ICPC competition; and then, on Nov 22, 2016, Twitter sent an email about suggestion based on the connection: Wesley may @wjomlex, she followed, and then, she found the blog:

http://www.questtosolve.com/browse.php

Actionable items:

Work on 1 - 3 medium level algorithm by myself, and then, read the solutions. Tell at least 1 - 3 differences compared to HackerRank medium algorithm.

Monday, November 21, 2016

Minimum Cost - HackerRank woman codesprint #2 - Summary (Series 10 of 10)

Nov. 21, 2016

Here are the summary of HackerRank woman codesprint #2 minimum cost 10 blogs. The main goal is to improve performance, best performer can work on the algorithm in less than 10 minutes/ 30 lines of code. It takes a lot of insights to work smart and avoid time-consuming ideas.

Each blog serves one individual purpose for Julia's practice with an ordinary algorithm, medium level difficult, entry-level one.

Blog 1 - performance in the contest
http://juliachencoding.blogspot.ca/2016/11/womans-codesprint-2-minimum-loss-in.html

Blog 2 - study after the contest
http://juliachencoding.blogspot.ca/2016/11/womans-codesprint-2-minimum-loss-after.html

Blog 3 - Java TreeSet class - implementation in Java
http://juliachencoding.blogspot.ca/2016/11/java-treeset-study-minimum-loss.html

Blog 4 - C++ Set class - implementation in C++
http://juliachencoding.blogspot.ca/2016/11/c-14-set-class-study-minimum-loss.html

Blog 5 - C# SortedSet, SortedDictionary - implementation in C#
http://juliachencoding.blogspot.ca/2016/11/c-sorteddictionary-minimum-cost.html

Blog 6 - failed code study
http://juliachencoding.blogspot.ca/2016/11/minimum-cost-study-failed-code-partial.html

Blog 7 - Simplicity comparison, performance presentation
http://juliachencoding.blogspot.ca/2016/11/minimum-cost-comparison-of-simplicity-c.html

Blog 8 - Binary Search Tree algorithm, classical solution - Julia's favorite
http://juliachencoding.blogspot.ca/2016/11/binary-search-tree-algorithm-supports.html

Blog 9 - To be determined.
http://juliachencoding.blogspot.ca/2016/11/minimum-cost-hackerrank-woman.html

Blog 10 - inspiration by verse from tennis world champion - Roger Federal

When you're good at something, make that everything. 


Minimum Cost - HackerRank woman codesprint #2 - Summary (Series 9 of 10)

Nov. 21, 2016

Plan to come out the idea for the slot - series of No. 9 of 10.

Roger Federal used to inspire Julia a lot with the verse. "Make your strength to everything."

Julia only survived on the contest of woman codesprint #2 with first one medium algorithm, from 3 medium, 2 hard algorithm, total 5 algorithm. So, she decided to make this medium algorithm to everything, blog the practice with a series of 10 blogs.

Ideas can be any one of them:
 1. Find things to work on through studying submission, performance discussion, statistics of most popular solutions among C++, Java 8. 2.

 2. Just warm up the algorithm with 1 -5 practices, different ideas.

 Will come back soon. Julia's most favorite verse to motivate herself to serve better through blogging. Every effort makes different. Every blog counts to progress, no matter how small it is.

Life is like a game of tennis, the player who serves well seldom loses. 

Sunday, November 20, 2016

HackerRank stone division - recursive design study (series 4 of 5)

Nov. 23, 2016

Introduction

It is time to get some training on recursive function. Learn a few terms related to recursive function first, Julia can describe what problems she had in the contest. She had problem to come out a simple recursive function, after so many years hard working as a scholar and full time programming experience.

She missed the important part to work on, recursive step, build a recurrence formula.  
C# solution - copy the code from editorial notes: score 50 - maximum score, pass all test cases

In the above C# solution, line 80:
ans = Math.Max(ans, 1 + ( (pile/runner) * rec(runner) ) );

Study Recursive Function
Julia googles searched the recursive function, and then she found 3 things to work on. And then, she noticed that her study lacks depth of industry experience. She found an engineer on stackoverflow.com, and then she spent a few hours to read his blog. Great teaching about recursive.
 

Google Search: recursive function common mistakes

Choose some content to read:
  1. university lecture notes - umd.edu
  2. IBM article
  3. lecture notes - MIT
  4. recursive function blogs
Here are the details. 

1. university lecture notes - umd.edu:


Write down keywords:

c - core dump 
c - compact code - recursive solution 
h - How to think recursively?
s - stack space - recursive vs iterative 
     O(n)  vs  O(1)
    stack size - several megabytes - 1000 recursive calls 
t - tail-recursive function 

Google those keywords, and get more readings.


Notes:
Inductive definition 
inductively-defined 

Bug source: state changes
Ideas to avoid bugs:
    No variable does double-duty
    Be certain that all variables hit the state they are supposed to be in when the loop restarts. 

One rule: 
Assign a value to a variable only once and NEVER MODIFY IT!

1. Reusing a variable 
2. Conditional modification of a variable 
3. Loop variables

Base case proof. 
Inductive step proof. 

Two common mistakes:
1.     The base case is missing entirely. or the problem needs more than one base case but not all the base cases are covered. 
2.     The recursive step doesn't reduce to a smaller subproblem, so the recursion doesn't converge. 

base cases
recursive steps

decompose a recursive problem into recursive steps and base cases
when and how to use helper methods in recursion
understand the advantages and disadvantages of recursion vs. iteration 

Structure of recursive implementations
- base case
- recursive step

A direct recursive implementation 

Don't expose the helper method to your clients

Temporary state 
Evolution of the computation

Recurrence relation 
Helper methods
Choose the right recursive subproblem


4. Eric Lippert's blog about recursive function



More reading:
stackoverflow->
recursive question/ answer by Eric Lippert
->       Eric Lippert

Recursion series:
Part 1: 
Teach how to think about recursion 

Julia's notes
recursive way to think about a list emphasize the similarity of a fragment of the list to the whole list. 
recursively define a list as either
1. the empty list with zero items on it, or
2. an item followed by a list

appear to be a circular definition, but it is really not. 'Spiral' definition

All recursive functions follow the same basic pattern: 
Am I in the base case? If so, return the easy solution. 
Otherwise, figure out some way to make the problem closer to the base case and solve that problem. 

bottom out - base case 

A binary tree is either:
an empty tree, or 
a value associated with two binary search trees, called the left and right child trees. 

inductive hypothesis - 

1 million nodes - balanced tree - 20 recursive depth - 210 = 1024, so 1 million is around 220

"anonymous locals" - 

callee's frame   -  caller's frame  - current activation frame 

the temporary variables are spelled out 
each recursion happens on its own line

Follow up after 3 months


Feb 23, 2017

Because of this study, Julia looked into stackoverflow.com, and then she found the code review on stackexchange.com. She did great job to help herself, from a failure to solve a recursive function to study recursive function, know one person/ a blog/ code review site, she is no longer a lone coder. She asked a lot of questions and tried to answer a few questions. She tasted the success of solving problem with other's help. 

HackerRank stone division - after the contest (series 2 of 5)

Nov. 20, 2016

Introduction
HackerRank - woman codesprint #2 - stone division

Julia learned one algorithm a time after the contest. Every time she fails to solve an algorithm in the contest, it is her favorite learning time.

Spend 20 minutes to study Editorial Notes about the solution first.

 1. Julia's C# solution followed the study: 
After one hour study of the code converted in C#, Julia found out that she overcooked the solution, got too far to do the work instead of being lazy letting recursive function play the role.

First time again in a few month after she worked on linked list, she found out that she had to learn the tip again to fully take advantage of recursive function, give the confidence to allow recursive function to take care of business.

2. Let us learn the recursive again, let it do the beautiful work. And Julia take a break.

C# solution - copy the code from editorial notes: score 50 - maximum score, pass all test cases
https://gist.github.com/jianminchen/85980e8f52c701027fbf25a8f2293e96

Play with code, remove memorization, score 16/50, fail test case 11 and up
https://gist.github.com/jianminchen/de08d6a479e059b4238bec1d23ab6e12

Continue with a blog about recursion study.


HackerRank - woman codesprint #2 - stone division - in the contest (series 1 of 5)

Nov. 20, 2016

Problem statement

Stone division

C# submission - need to continue to work on the solution
1. score 0, only pass the sample test case


2. second submission with more problems

Julia's idea to solve the problem:
She stopped on her third algorithm, worked so hard, over 5 hours, messing with recursive/ bugs with concatenating the string - her favorite test case: 2 3 4 6 8, n = 12

She tried so hard to work out on this test case:
    2   3  4  6  8   12
2  T   F  T  T  T   T   -  can divided by 2? 
3
4 
6 
8
  She worked on the backward to find all possible routes - for example, 12, 6, 3, or 12, 6, 2 etc. 


Performance review:

It is hard to review the performance. Because Julia worked damn hard on this algorithm, she tried to push so hard and then she almost fell to sleep, she knew that she should cut the route she took; There is a lot of extra work she carelessly brought into the above submission.

Will continue later.

Binary Search Tree - the algorithm supports the idea to solve "Minimum Cost" (series 8 of 10)

Nov. 20, 2016

Problem statement:

https://www.hackerrank.com/contests/womens-codesprint-2/challenges/minimum-loss



Julia spent a lot of time to try to get used to work on contest algorithms on HackerRank. She saw a lot of efforts she put in, but she was just the beginner of competitor programmer, maybe 10% compared to best talent in the world. 

But, nothing can stop her to mentor herself to get through the stage, and become more confident on the competition. She started to know what to work on in the contest/ after the contest, understand most important things to do in order to get better. 

One thing about the algorithm "Minimum Cost" is to handle the time complexity. Binary Search Tree is good enough algorithm to handle the scale of algorithm. 

Look into the detail of description of problem:
next n years - the span of years - 200000, 0.2 million years, 

n >= 2 and n <= 2 * 10^5, so n^2 will be around 4 * 10^10, 
nlogn is best fit, since logn = 5, if 10 is base of log function. 

No matter the solution is written in C++ or Java, most popular languages used in the top performers, they all chose to use binary search tree based on class, Java TreeSet is most popular one, and then, C++ Set which is also based on binary search tree. 

Here is the just thoughts Julia likes to write a blog about the series, to make it to series of 8 of 10. 

So, in order to understand the contest, competition better, as a former teaching assistant of computer science, Julia likes to study the solution of basic binary search tree, implemented in the way to return the minimum difference as a loss. 

A lot of people stopped in the contest after this second algorithm. Julia felt the same way the difficulty. But she just likes to take one algorithm a time. Do not try to push herself too hard. She stopped on her third algorithm, worked so hard, over 5 hours, messing with recursive/ bugs with concatenating the string - her favorite test case: 2 3 4 6 8, n = 12

She tried so hard to work out on this test case:
    2   3  4  6  8   12
2  T   F  T  T  T   T   -  can divided by 2? 
3
4 
6 
8
  She worked on the backward to find all possible routes - for example, 12, 6, 3, or 12, 6, 2 etc. 

Using Binary search - therefore, it is easy to find the minimum price, O(nlogn)
Maintain a binary search tree!

Study this C# solution using Binary search tree:

https://gist.github.com/jianminchen/c910f5d1f37309c70b489e6c75b0678c

Very classical solution using binary search tree, and very clever solution.

Memorize the solution. Warm up the solution sometimes in the future.

Minimum Cost - comparison of simplicity - C# vs C++ (series 7 of 10)

Nov. 20, 2016

One thing Julia is learning in the contest is to write simple code, avoid complicated situation, cut the executable paths/ giant expression/ complicated things to eat time.

One thing Julia likes to do is to compare her C# solution using Dictionary<Int64, string> to this C++ solution, she just found out that her logic thinking can be simpler.

C# solution written by Julia:

https://gist.github.com/jianminchen/af474846d81b96f4e70fc1a5866dca15

C++ solution: (rank after 400 before 500)

https://gist.github.com/jianminchen/0e98727e40937c11594b0be8ea496885

Compared to top performer (rank 6 out of 1500) - C++ code, just less than 30 lines of code:

https://gist.github.com/jianminchen/8a448bac7de8ad3667b125abe3544e5d

Very close to my idea in C# - by a Microsoft Bing employee -

Nickolas - Topcoder writer, rank 84 of contest.

https://gist.github.com/jianminchen/7ef0dcb49662f277fda36742da5fa57c

Study all her submission on this contest ! - figure out the style I should learn.

Julia's comment: 

Know the problem inside out, a lot of ideas and implementation. One day, Julia can choose best one to make it less than 10 minutes a medium algorithm as well. 

Visual facts to encourage Julia work hard, and continuously improve! The goal is to shorten the time to performance. It is also practical goal, achievable!

Here is the graph Julia likes to share the research she did through the contest:

Case 1:
algorithm: minimum cost
100 minutes vs 8 minutes - over 10 times more to spend on the performance! Julia, you have a big room to improve!

Case 2:
algorithm: stone division, revisited
329 minutes to come out a solution, score 0 of 50; extra 3 hour to work until 2:00am

Compared to 50 minutes full performance, less than 40 minutes.
500 minutes -> 40 minutes, 10 times more! I just could not believe that. The research and development I did over 6 hours, does not help. Best performer uses 40 minutes to do everything, including his research, coding and testing etc.





Minimum Cost - study failed code - partial score 17/ 35 (series 6 of 10)

Nov. 20, 2016

In order to improve the performance on HackerRan contest, Julia tries to look into things she can work on, help her to gain some confidence, relax more when she has a contest to compete.

She score full score 35 on the Minimum cost - HackerRank woman codesprint #2, but she likes to go to extra mile to find out things:

One of failed code with test cases, try to figure out the issue, do some analysis of code.

https://gist.github.com/jianminchen/7401c0b6108659df7d03abd2576cb1cf


Questions:

It is run-time error, why it is not timeout or related to issue. Look into later.

Actionable Items:

Do more research on this, and then figure out how HackerRank will report the runtime error/ timeout. At least know the difference.




C# sortedDictionary - Minimum Cost Algorithm - an idea to write code (series 5 of 10)

Nov. 20, 2016

1. Introduction:
Julia spent time to write a C# solution in HackerRank - woman codesprint #2, using Dictionary<Int64, int> in the contest, here are the detail:

Here is the problem statement:
https://www.hackerrank.com/contests/womens-codesprint-2/challenges/minimum-loss

Julia's C# solution:

https://gist.github.com/jianminchen/af474846d81b96f4e70fc1a5866dca15

The ideas used in the algorithm:

Sort the array with house price.

Use bucket sort similar idea to go through each bucket, compare to previous if the current is less than minimum loss or not. Each bucket keeps the two value - max/ min value.

2. C# solution - Go deep to search for ideas to improve and strength the skill:

1. There is a solution written in C#, much simpler and smarter than Julia's C# code:

https://gist.github.com/jianminchen/c382bc1b40e47c2740a25abcaeffb846

Based on the assumption that housing price is different for each year, but I did not find the word in the problem statement.

2. Using Binary search - therefore, it is easy to find the minimum price, O(nlogn)
Maintain a binary search tree!

Study this C# solution using Binary search tree:

https://gist.github.com/jianminchen/c910f5d1f37309c70b489e6c75b0678c

3. Performance comparison among Java TreeSet, C# SortedSet, SortedDictionary:

Now, she likes to write a C# solution similar to C++14 using Set, Java 8 using TreeSet. Now she will write using SortedDictionary.

C# solution using SortedDictionary, timeout, only score 17.5 of 20.
https://gist.github.com/jianminchen/3e978465798afbd7d611e90a8ad7af0c

using C# SortedSet, timeout, score 17.5 of 20.
https://gist.github.com/jianminchen/63c1ed68999f78a72250372eb58a6953

Look up on stackoverflow.com
http://stackoverflow.com/questions/14675108/sortedset-sortedlist-with-better-linq-performance

Java TreeSet code: Perfect solution, score 20
https://gist.github.com/jianminchen/3fce12eff5838fa10bff0792547d0779

Test code here:
https://www.hackerrank.com/contests/womens-codesprint-2/challenges/minimum-loss

Use LINQ only, no SortedSet, timeout
https://gist.github.com/jianminchen/83f0079acbcfc4b6de3f5b1aff6aa131

Dec. 1, 2016
StackExchange.com Code Review
Julia came out the idea to get help from top talent in the world, she chose stackexchange.com code review and posted a code review request, a few people gave out their contribution, one on LINQ, one on SortedSet, then, Julia learned the solution. The question was posted on Nov. 30, 2016, and then, it was solved on Dec. 2, 2016. Less than 3 days.

Using List<T> BinarySearch
Using List<Int64>, BinarySearch and Insert APIs. Score 24 ( maximum score 35).

https://gist.github.com/jianminchen/d6c675533578d50049c636e566695830

The stackexchange.com code review link:
http://codereview.stackexchange.com/a/148714/123986

Using SortedSet<T> GetViewBetween(), score 30 (maximum score: 30)
http://codereview.stackexchange.com/a/148727/123986

C# submission:
https://gist.github.com/jianminchen/2fda6d1d11b19d6b59f3d44822115927

C++ 14 Set class study - minimum loss - an algorithm - on the hackerRank (series 4 of 10)

Nov. 20, 2016

Julia likes to write a separate blog on C++ 14 Set class. She spent time to read C++ solution on algorithm minimum loss. She like to do some research on C++ Set

C++ Set underneath is a binary search tree.

Here is the problem statement:


Study code:
https://gist.github.com/jianminchen/bae3b7c5c3326213d1ff800aef47ebc8

https://gist.github.com/jianminchen/9098f545f0b750fe1cb4acd6a2c0b1b9


C++ Set analog in C#:
http://stackoverflow.com/questions/575406/what-is-the-c-sharp-equivalent-of-the-stl-set

SortedDictionary<T, U>

Actionable Item:

Study C++ 14 Set class, spend 30 minutes to go over all API - memorize all the APIs.

http://www.cplusplus.com/reference/set/set/set/

26 APIs

begin
cbegin
cend
clear
count
crbegin
crend
emplace
emplace_hint
empty

end
equal_range
erase
find
get_allocator
insert
key_comp
lower_bound
max_size
operator=

rbegin
rend
rize
swap
upper_bound
value_comp


Java TreeSet study - Minimum Loss - an algorithm in contest on Hackerrank (series 3 of 10)

Nov. 20, 2016

Julia likes to put a separate blog to work on the research on Java 8 / TreeSet class - underneath a binary search tree.

She was amazed that the code is so clean and easy to understand.

Study more Java submission with perfect score, best performance compared to Julia's performance.

https://gist.github.com/jianminchen/3fce12eff5838fa10bff0792547d0779


Google search keyword:

Java TreeSet C# analog

Stackoverflow:


Will get into more detail.