- Extra storage is not necessary. I agree with your advise on this.– Jianmin ChenJan 30, 2018 at 21:15
- I got complaint about memorizing the solution in mock interview. Since I choose to work on same 30 algorithms again and again on mock interview, I know all the common solutions and mistakes. But exploring new ideas are challenging still in the mock interview, I try to write simple code. Four variables to replace visited array are easy to make mistakes in interview, I think.– Jianmin ChenJan 30, 2018 at 21:34
- 2@JianminChen the purpose of programming interviews should not be to find perfect solutions, but to see your thought process, ability to split larger problems to smaller ones, and building up something that works through iteration. So rather than perfecting the solution to a small set of specific problems, I recommend to solve a wide range of problems.– janosJan 30, 2018 at 21:44
- I agree with you on this. It is not good to be opportunistic. But one popular saying is to write production ready code in interview, I also ask myself which one is more production ready code? More space less buggy or optimal space with more buggy variables?– Jianmin ChenJan 30, 2018 at 22:40
- I had a mock interview as an interviewer on Jan. 30, 2018, so I asked the peer to solve the algorithm; he gave exactly the same idea you advise, using direction array and also use four variables instead of visited array, he wrote 10 minutes but code has a few issues like grammar errors. Here is C# code I completed based on his code after the mock interview: gist.github.com/jianminchen/fca45bb38410b59f580f88a0051ae2a8– Jianmin ChenFeb 2, 2018 at 6:24
- I continuously studied and then I found exactly same idea advised by janos. Here is the leetcode discussion link: discuss.leetcode.com/topic/15558/…– Jianmin ChenFeb 10, 2018 at 23:40
- I wrote the implementation of the idea advised by janos. I did not really understand quickly about the idea by reading the above code review until I wrote the C# code based on Leetcode discussion, and then I found that the idea is exactly the same. Here is the C# code integerated all the above code review advices and avoid using extra array visited. gist.github.com/jianminchen/1adcda667cc22247df154a40fcc57d2c– Jianmin ChenFeb 10, 2018 at 23:43
- I wrote C# solution with optimal space O(1), using direction array to adjust direction automatically. Here is the link: leetcode.com/problems/spiral-matrix/discuss/407992/…– Jianmin ChenDec 7, 2019 at 1:47
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.
Tuesday, July 4, 2023
StackExchange | Code Review | Leetcode 54: Spiral Matrix
Here is the link.
Subscribe to:
Post Comments (Atom)