May 8, 2016
Problem statement:
https://www.hackerrank.com/challenges/find-the-merge-point-of-two-joined-linked-lists
Cpp solution:
https://gist.github.com/jianminchen/ce99505020ee58f2fd23ecd78bb2f19f
Value simple, easy question, solve the problem, learn from other submissions. From the simple ones, build up skills, feel more comfortable to solve moderate, difficult one later.
Submissions:
https://www.hackerrank.com/challenges/find-the-merge-point-of-two-joined-linked-lists/leaderboard
Julia's favorite code:
1. define a few functions, very well written:
length, position, common - use recursive function, very short function - 3 lines of code each function
https://gist.github.com/jianminchen/2ab387360a0ff2ef41c10c67219fd1c1
source:
https://goo.gl/J5WK7y
2. unbelievable short - only use for loop to do things:
https://gist.github.com/jianminchen/9d14ff515146af193c4bee660b0a6fb8
Question and answer:
1. What do you learn through the problem solving? Code submission study?
Julia likes to document the problems she found when she reads first 100 solutions, in order to improve the speed, accuracy, and avoid bugs - avoid repetition of same logic:
1. Best code she found so far:
https://gist.github.com/jianminchen/2ab387360a0ff2ef41c10c67219fd1c1
2. One is to use brute force, go through each node in the first list, compare to each node in the second list; The algorithm is not optimal.
3. Shortest time to write the code, in less than 20 lines:
https://gist.github.com/jianminchen/9d14ff515146af193c4bee660b0a6fb8
3. Repeat same code twice - if/else statement - avoid two cases, simplify to one case.
4. Same code as Julia does, but better code:
https://goo.gl/NXTurm
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.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment