C sharp codes beats 91.5% of c sharp


  • 0
    public class Solution {
    public int[] TwoSum(int[] nums, int target) {
        Hashtable ht=new Hashtable();
        for(int i=0;i<nums.Length;i++)
        {
            int x=nums[i];
            if(ht.ContainsKey(target-x))
            {
                int[] rs={(int)ht[target-x]+1,i+1};
                return rs;
            }
            else
            {
                ht[x]=i;
            }
        }
        return null;
    }
    

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.