Java HashMap 基本操作在这题里
public class Solution { public int[] twoSum(int[] nums, int target) { Map<Integer, Integer> map = new HashMap<Integer, Integer>(); // Constructor for(int i=nums.length-1; i>=0; i--){ int adder = target-nums[i]; if(map.containsKey(adder)){ // Check if map has the key return new int[] {i+1, map.get(adder)+1}; // Get the value from the key } else{ map.put(nums[i], i); // Add new key-value pair } } return new int[] {-1, -1}; } }
2019年1月02日 00:55
Remote windows 10 is a rewards program that lets you make credit scores for searching on desktop.
2019年5月29日 19:02
Thank you for posting this sort of splendid article! I located your website perfect for my desires.
2019年6月20日 02:01
Nice write-up. A good article always come up with new and exciting information. Keep up the amazing work.
2022年4月28日 00:38
I really appreciate your blog, it is really helpful for all. Keep blogging to attract reader's attention
Visit our website for best student visa & immigration consultation service, We are best <a href="https://espiconsultants.com/visitors-visa/">Visitor Visa Consultants in Vadodara</a>
2022年4月28日 01:25
Great blog. Thank you for sharing information
Keep Going on.
Visit our website for smart lights, motion sensors, home automation devices. We are leading Home Automation Device Manufacturers in Vadodara
2022年4月28日 19:05
I like you article with informative info. keep up the amazing work.
2022年4月28日 19:46
Great share! Amazing write-up!
I like Your articles and your information is so clear. I liked it. I appreciate your work
Visit our website for best offers on apple products, We are authorised Apple iPhone shop in Vadodara.
2022年8月01日 21:32
Do you have an account in Bank of India, If yes, then you might be happy because of the features and services of BOI which they provide to their customers. BOI allow their customers to register for Internet banking online with new requirements?With this, Bank of India net banking services, customer of BOI can access the complete banking services in online to transfer the funds, Bank of India net banking login generate statements, personalized view of account or more. After registration, you can reset BOI login password online if required too. These are some basic points that need to check before going for online registration of Bank of India internet banking facility, which we are going to discuss below from BOI history.