diff --git "a/problems/0225.347円224円250円351円230円237円345円210円227円345円256円236円347円216円260円346円240円210円.md" "b/problems/0225.347円224円250円351円230円237円345円210円227円345円256円236円347円216円260円346円240円210円.md" index 13b742f839..3de300c781 100644 --- "a/problems/0225.347円224円250円351円230円237円345円210円227円345円256円236円347円216円260円346円240円210円.md" +++ "b/problems/0225.347円224円250円351円230円237円345円210円227円345円256円236円347円216円260円346円240円210円.md" @@ -111,7 +111,7 @@ public: } }; ``` -* 时间复杂度: push为O(n),其他为O(1) +* 时间复杂度: pop为O(n),其他为O(1) * 空间复杂度: O(n) ## 优化 @@ -158,7 +158,7 @@ public: } }; ``` -* 时间复杂度: push为O(n),其他为O(1) +* 时间复杂度: pop为O(n),其他为O(1) * 空间复杂度: O(n) diff --git "a/problems/0349.344円270円244円344円270円252円346円225円260円347円273円204円347円232円204円344円272円244円351円233円206円.md" "b/problems/0349.344円270円244円344円270円252円346円225円260円347円273円204円347円232円204円344円272円244円351円233円206円.md" index 26a9286dc9..138067e360 100644 --- "a/problems/0349.344円270円244円344円270円252円346円225円260円347円273円204円347円232円204円344円272円244円351円233円206円.md" +++ "b/problems/0349.344円270円244円344円270円252円346円225円260円347円273円204円347円232円204円344円272円244円351円233円206円.md" @@ -121,7 +121,7 @@ public: ## 其他语言版本 ### Java: - +版本一:使用HashSet ```Java import java.util.HashSet; import java.util.Set; @@ -159,7 +159,28 @@ class Solution { } } ``` - +版本二:使用Hash數組 +```java +class Solution { + public int[] intersection(int[] nums1, int[] nums2) { + int[] hash1 = new int[1002]; + int[] hash2 = new int[1002]; + for(int i : nums1) + hash1[i]++; + for(int i : nums2) + hash2[i]++; + List resList = new ArrayList(); + for(int i = 0; i < 1002; i++) + if(hash1[i]> 0 && hash2[i]> 0) + resList.add(i); + int index = 0; + int res[] = new int[resList.size()]; + for(int i : resList) + res[index++] = i; + return res; + } +} +``` ### Python3: (版本一) 使用字典和集合

AltStyle によって変換されたページ (->オリジナル) /