Saturday, January 6, 2018

Leetcode 18: 4 sum

January 6, 2018

Introduction


I had a mock interview at 10:00 PM in May 5, 2018. I learned some JavaScript from the peer, but also I had to learn how to help the peer write a brute force solution using JavaScript. I had to write down the four loops and then also write the start index for each loop for the peer.

Brute force four loops


It is the first time I had to show the peer how to write brute force solution using four for loops. And also it is my job to fix the start index for the peer as well.

I made the comment to remove the line beside a while loop, and then line 12 to line 15, I changed the start index to i + 1 instead of 0, likewise to apply k and l.

Code to review


Here is the JavaScript code written by the peer in JavaScript, passing all test cases on mock platform. It is also a brute force solution.

I have to learn how to help the peer write a brute force solution first, and then let the peer understand the solution and get the good feelings to solve the problem.




No comments:

Post a Comment