[Day0]1.Two Sum

After much thought, I title it as "Day0" but not "Day1". This is not purely out of the custom of a CS student, also, it is because I regard it as an informal one and a simple test. (I have to admit that there is a little prejudice for zero.Hah~)
Now, I am ready to plant a flag that I will solve at least one problem a day on Leetcode for next several(?) months. If, though I truly hope I can stick to this and publish everyday, if there is emergency, I will make up on other idle time!

Today's problem is really a simple one. But in contrast, the top solution given by the website is a beautiful one. And the top solution only run 8 ms, which really surprised me.
O(n) VS O(n*n)? To be honest, I don't know much of how to compute the complexity of the algorithm. ->_->

public static int[] twoSum(int[] nums, int target) {
    int [] a=new int [2];
    for(int i=0;i map=new HashMap();
    for(int i=0;i

你可能感兴趣的:([Day0]1.Two Sum)