Showing posts with label HackerRank. Show all posts
Showing posts with label HackerRank. Show all posts

Monday, March 12, 2018

How to predict the candidate the possibilities of success?

March 12, 2018

Introduction


It is 20 minutes talk by Gayle Laakmann McDowell on hackerrank, called "Deconstructs the engineering interview process". Here is the link.

Interesting talk


I like to write down a few arguments and then think about them more carefully.

Ensure that the person is smart. The person can learn the technology and also ... 15:00/ 26:20
The algorithm is challenging, multiple hurdles, ..., no cool math,  ... 16:05/ 26:20
Talk about boot camp, transition to IT career, ... 18:00/ 26:20
He is very smart person, ..., 19:30/ 26:20
Bias, try hard? do it best? ..., 20:00/ 26:20
Bar raiser? ..., 23:00/ 26:20
Consensus? ..., 24:00/ 26:20
Are the person smart? attribute? 24:30/ 26:20


Julia's notes



I like to put down some notes here first, and then decide to highlight something interest.



Interview purpose?
to predict who you want to hire, who will make a good employee.


Argument: why the interview is not realistic?

interviews should be realistic

Argument 1:

a good interview is one that is predictive and good candidate experience too


Argument 2:

it’s also not predictive because all you’re really testing is someone’s knowledge


What is to simplify their intelligence? How to assess the candidate's problem-solving skills?

When you stick to basic computer science, when you stick to basic design and algorithm, they should be there if the interviewer is doing the right thing, to essentially assess the candidate’s problem-solving skills, to simplify their intelligence.

And problem-solving skills and intelligence that is actually a very, very important thing for a developer.

Challenging, hard problem, not see the problem before, to prepare a check list:

they need to ask questions that candidates haven’t solved before that are challenging, that are challenging because it’s actually a hard problem and not because it tests obscured knowledge and see how the candidate solves a hard problem.

How to move through the problem? can you make progress on it?

What is qualitative analysis? 

Dynamic programming algorithm?

Weak problem solving skills, never do well in those questions.

candidates who are just ok, given them 10 of questions, and then he/ she will do very good since dynamic programming is incredibly formulaic. So ok candidate looks like a great candidate. So dynamic programming is not a very good interview question.

There are so many other problems out there that are going to not be as biased.

How to tell that the person is code money, not done anything challenge?

You want to find people who will be good, who will be able to do cool things, not actually people who have.

What kind of people do you need to be careful in the interview?

People who do a really good job of making what they say sound more complex than it really is.

What to focus on?

You should really focus on figuring out how this person deconstructs the problem and it’s okay to give hints and it’s okay if the person actually solves a problem with a hint. Don’t ding him or her for that.

What to avoid?

based on a trick or which is based on a math formula

How to define hard question? How to separate hard question because of obscure knowledge?

No tricks, not cool math, things whatever -> good hard question

Having questions that have multiple like hurdles, that can be multiple parts to the problem, so it can be a bunch of fault questions. It can also be just a problem that has multiple optimizations to get the most...

A good rule of thumb there is, you’re kind of struggling and you’re trying to give them a hint and you have a part-time figure out how to give them a hint without giving everything away, that’s probably not a good question.


Insecurity, how to deal with it? 

given an example using binary search tree,

Please google into a self-fulfilling prophecy?

Saturday, January 14, 2017

Hackerrank week code 28 - Suffix Rotation

January 14, 2017

Introduction
Life is not easy to compete the week code on Hackerrank, now Julia's ranking is following behind around 2900 out of 9985 at 11:54am, 1/14/2016. In order to get into the top 25%, she has to continue to work on the problem solving. It will be a lot of fun, a lot of mistakes, and trial and errors.

Have some images to show the progress first, comparison to one in the ranking of 2000:


Comparison to one in the ranking of 1000:


The Great XOR

Julia just found out through the above graph, she had some issues with the algorithm The Great XOR. Spent 5 minutes to look into detail. She did not have any test case failure when she worked on the algorithm, the hackerrank has issues to run so slow, only at the end of day, all test cases will be run. She lost almost 10 points on the algorithm.

Usually, Julia likes to focus on easy and medium level algorithms, now in order to get a bronze medal, she has to learn to work on hard, advanced and expert algorithms, and try to do some research, read the discussion, and come out a simple idea to make extra points.

Lucky Number Eight
Julia did remember the algorithm was scored 18 instead of 10.80, now there are over 5 test case timeout. Six more test cases are added and she failed all of test cases because of timeout.

Comparison to rank 515



Instead, Julia can choose to walk around the outdoor, and get some physical exercise done first.


Study, research, code 

Suffix Rotation - problem statement

1. Work on a test case:
string abc, there are 6 variations:
abc-> no rotation, answer is 0
acb-> abc,  1 rotation
bac->acb->abc,   2 rotations, second rotation starting from c
bca->cab->abc,  1 rotation, but circular rotation 2 times
cab->abc, 1 rotation
cba->bac->acb->abc, 2 rotations

2. Work on a test case with multiple instances of char:
string abcbb, what is difference?
abbbc,
if we use counting sort, we can determine the char by counting the number, and then calculate difference.
abbbc
c should be in position of 2, starting from index = 0, but actually it is in position of 4
rotation twice move 4 to 2, and also one of b is in position of 4, it should be in 2, also moved forward.

3. Work on a test case, abcdb,
so c should be in position 4, but it is in 2; 4 - 2 = 2, 1 rotation,

Try to use recursion solution to gain a few points first. And get some ideas about the issues.

Test Case: "cababc"

After more than 3 hours coding, at 10:13pm, Julia studied the discussion related to the test case, Julia found out that there are more than one solution, but need to find minimum move.

string cababc, using her naive solution, it will take 3 moves:
cababc ->
ababcc ->
aabccb ->
aabbcc

but the minimum move only needs 2 moves:
first 'a' is to use the second 'a' in the string "cababc", after first rotation, the string will be "abccab", and the second move is to use second b in the string "abccab", then final string "aabbcc".

How to get the minimum move? Use brute force, then calculate each option for any char from a to z.

Try to find something to think about:
cababc->   ababcc
                  abccab

From two strings to choose a small one, how to choose?
abccab  -> aabbcc
ababcc  -> aabccb

Google Search: suffix rotation minimum

ACM ICPC 2003 - the algorithm discussion is here.

One more reading is here.

Review Suffix Array and Longest Common Prefix

Study code review

Ashton and String Hackerrank


my favorite algorithm teacher - JS1

Actionable Items:

Work on the minimum value by simply comparison. Try to get at least 1 point first.

1. check into to document latest progress:
1/15/2017 11:05am
Using my code in C# to test the cases seen in the discussion - link is here.

test case 1: hackerrank - 6
test case 2: suffixrotation - 9

Using queue, and calculate all the possible selections. 

But my C# submission still scores 0, pass test case 0, and time out 1 and 2, and runtime error test case 3 on 1.97s. 

Rotation definition - misunderstanding 

2. Need to look into the rotation definition, see if it is making sense or not. 

Choose index bigger than prior move. 
but, at the index, perform circular rotation in either direction. 
So, work on the example, abcdefjghi, at index 6, with char j, can rotate clock wise or anti-clockwise. 

jghi -> anti-clockwise -> ijgh -> hijg ->..
jghi -> clockwise ->  ghij -> hijg ->..

So, work on the example: cababc
first work on index 0, work on second a, 
                                                      clockwise, abccab
                                                      anti-clockwise, abaccb
                                   work on first a, 
                                                      clockwise, ababca
                                                      anti-clockwise, accbab

and then, work on second char - index = 1, there are 4 choices. 

Because Julia's C# code has wrong answer, probably it is because of her rotation misunderstanding, missing two cases. 

Good workout and great learning 

Suffix Rotation C# practice - score 0, but perfect learning experience. Julia learns the importance to challenge herself to work on hard algorithm, come out the solution to work ok with sample test cases. She spent more than 5 hours to work on the problem on Saturday January 14, 2016 and two more hours on January 15, 2016. 

Have a very excellent experience to work on string manipulation, queue, and also read all discussions to get basic test cases with expected results. 

Make some points on hard algorithm in future week code contest. It seems that week of code is most popular contest on HackerRank, and the difficulty level is up-to-most-top-standard. 

After contest 

code study - link is here. 
Code review - rewrite the C# code, study and debug, code is here. 

More study on the code, and 2nd version before code review, code is here.
3rd version, code is here.

Status report

Julia finds out that there are so many solutions to study, and she does not have a lot of time to catch up so many things. Just go one by one.

She will work hard on the algorithm, through the contest, she understood that it is most important to stay humble, and she is thankfulness to enjoy the practice. Just learn one thing a time.

Thursday, January 12, 2017

HackerRank - week of code 28

January 12, 2016

Introduction
Julia did some research by reading the article written by Dr. Patrick Cohn about tennis match performance and training, the article "Tennis Psychology: Practice Confidence vs. Match Confidence", she learned a few things. Here are her favorite quotes:

-----  great thoughts about tennis sports  - coding should also be the same  ---------

Let’s start by answering a basic question: What does it mean to play with trust? When you play with trust, you allow yourself to play freely – you have faith in your practice. You don’t grind on your technique or over coach yourself in matches because you are confident that you can rely on your practice. You just react to the ball, knowing your training will carry you.

Through practice and repetition – a lot of it – your body learns how to hit shots effortlessly, instinctively. Meaning with enough repetition and practice, you can hit shots without thinking about how to hit shots. You should think of competition as a “closed book test” to use a schoolwork analogy. You’ve studied (practiced) for the test. In competition, it’s time to trust what you studied. 

How does your trust break down all of a sudden when you play in a match? Many mental game or tennis issues can affect your level of trust in matches. A lack of confidence and cause your trust to not show up. Indecision is another barrier to trust. Fear of failure can kill the soundest strokes. Perfectionism can cause you to focus too much on perfect strokes and not enough on strategy and playing smart shots.

What can players do to improve their trust in matches?
Trust starts with having a balance in your practice routines. Practicing the right way will help you improve your trust in matches. The key is to practice like you compete.


-----   end of article excerpts ---

Go over again and again - four times!

Julia has faith in her practice! 
Julia has faith in her practice!! 
Julia has faith in her practice!!! 
Practice is getting better. 

So, Julia learns a few things here: 
notes will be written here later. 

She understands that it is very important for her to put herself on stress training daily, therefore, she did work on the week of code 28 so patiently, specially on the algorithm "Lucky Number Eight". She still likes to write a recursion function and review her favorite study blog written in less than 2 months - Nov. 24, 2016.

Contest workout

So far, she ranked 1480 out of 9215 on January 12, 2017, 11:23pm

One of Google employee cui aoxiang - performance unbelievable. She just kept finding new faces from Google, facebook, and also extraordinary performance. Next time, study her code and post some thoughts here.

Another good player from google. Click here.


Monday, July 25, 2016

HackerRank - world codesprint #5 Longest increasing subsequence arrays

July 25, 2016

Problem website:
https://www.hackerrank.com/contests/world-codesprint-5/challenges/longest-increasing-subsequence-arrays

Analysis from editorial:
Because we must use numbers from  to fill each array and we must be able to build an -element LIS for each array, we know each number from to  must appear in the array in increasing order.
We can select  positions where  to  will be placed such that  is placed in the first selected position, ,  is placed in the second position, , and so on. To avoid overcounting, we impose that there is no  before , no  between the position of  and , and so on. Note that after , we are free to place any value  we want.
For each chosen arrangement, how many ways are there to fill the remaining gaps? There are  unfilled cells and there are  values we can use to fill each position (except the segment from , which can accommodate until ). If we let , we can place .
If we loop over the values of  from  to , then:
Note that after we place the values in the last segment of length , we're left with an array of length  in which the last element must be . That's why we can only choose  integers.
This has a complexity of , provided you precalculate properly.
C# code to study: