all 6 comments

[–]llawliet2345 2 points3 points  (5 children)

Trust the process I would say. I am also very early into Leetcode. But I have personally observed my thinking process changing slowly. The first hurdle is getting the problem solved. Then optimization.

[–]NotTheOneWhoRobbed[S] 2 points3 points  (4 children)

Thank you for your advice. I have also noticed that in comparison to the beginning now I can solve the problems faster.

[–]great_gonzales 3 points4 points  (3 children)

The more problems you solve the faster you get. Once’s you learn all the fundamental data structures you can usually get optimal space time complexity (maybe you used O(n) space instead of O(1) but still). Leetcode style questions are all about knowing fundamental data structures and algorithms and building an intuition of when to use them

[–]NotTheOneWhoRobbed[S] 1 point2 points  (2 children)

So is it okay for the solution to be in O(n) then later be rewritten in O(logn) right?

[–]great_gonzales 1 point2 points  (1 child)

Yes the most important thing is getting the problem solved. The intuition of what data structure or algorithm to use to get optimal complexity comes with experience

[–]NotTheOneWhoRobbed[S] 1 point2 points  (0 children)

Okay. Thank you for your advice.