I'm currently usng leetcode to prepare for interviews. Here is the problem I ran into, pretty simple one. Two Sum:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1].
And here is my solution, which time complexity is O(n) and space complexity is O(n). enter image description here
The detail shows that it's runtime is pretty slow, which is even beated by solutions with O(n)^2.
I take it for granted that lower time complexity means faster runtime. And now I'm confused. What 's the relationship betwwen run time and time complexity. And what kind of solution is expected in an interview ?