Algorithm
1.?Two Sum
Given an array of integers, return?indices?of the two numbers such that they add up to a specific target.
You may assume that each input would have?exactly?one solution, and you may not use the?same?element twice.
答:
class Solution {
? ? public int[] twoSum(int[] nums, int target) {
? ? ? ? int[] answer = new int[2];
? ? ? ? HashMap<Integer, Integer> map = new HashMap<>();
? ? ? ? for (int i = 0; i < nums.length; ++i){
? ? ? ? ? ? map.put(nums[i], i);
? ? ? ? }
? ? ? ? for (int i = 0; i < nums.length; ++i){
? ? ? ? ? ? int b = target - nums[i];
? ? ? ? ? ? if (map.containsKey(b) && i != map.get(b))
? ? ? ? ? ? ? ? return new int[]{i, map.get(b)};
? ? ? ? }
? ? ? ? return answer;
? ? }
}
Review
How Browsers Work: Behind the scenes of modern web browsers - HTML5 Rocks
Learn how the browser works, but I need more time to finish this
TIP
在瀏覽器前端打開跨域鏈接,需要傳遞參數(shù)時(shí)拧揽,使用Windows.name和postMessage()
Share
最近開始學(xué)習(xí)VUE铝宵,上述文章是VUE作者建議的新手學(xué)習(xí)VUE的順序累舷,下一階段的學(xué)習(xí)以VUE為主