1.Given a string, write a function that return if it is Palindrome. This wasn't asked directly but from interviewer example i was need to understand that this function must ignore all spaces and special symbols. 2. Given an array, write a function that return true if any 3 elements of this array can sum to 0. My first solution was the simplest and far from best which result in O(n^3). Then interviewer asked me to improve to improve it to O(n^2). This give me a hint that i can use Hash to reduce complexity.
Anónimo
As I wrote I used HashSet to store all values so I can for every pair of numbers check if there is negative one in HashSet istead of thrid for so overall complexity will be reduced to n+n^2 which is O(n^2)