I am kinda puzzled at some of the array questions - which are marked "easy" but does take me a few tries to get it right - sometimes I have to rewrite the whole solution again in completely different way.
For example, this question:
https://leetcode.com/problems/remove-duplicates-from-sorted-array/
Initially I started with three for-loops solution, it worked fine, but exceeded the time for the last testcase (161st test case) which has huge array numbers.. it did make me chuckle :)
Question is, how does one go about looking at the problem (such as above) and come up with optimal solution? I mean after reading out a bit, there was an easier two pointer solution that i could code it up in less than 3 minutes. I used C, but there was also a C++ solution using vector which was like single liner.