[問題] 未排序的陣列,演算法相關問題

看板CSSE (電腦科學及軟體工程)作者 (無法顯示)時間14年前 (2010/05/08 11:29), 編輯推噓3(302)
留言5則, 3人參與, 最新討論串1/13 (看更多)
given two unsorted arrays X and Y, each contains m and n numbers, separately. design an algorithm so that, given a number d, it could determine if there exists two integers i and j, such that X[i] + Y[i] = d use less than O(m*n) running time 我想請問這題大致上從哪方面下手會比較簡易 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.228.27.232

05/09 01:56, , 1F
這個問題,借一下merge sort的解法就行了.
05/09 01:56, 1F

05/09 03:26, , 2F
merge-sort的解法願聞其詳
05/09 03:26, 2F

05/09 09:57, , 3F
是來自於你的解的提醒(不要O(m*n)->那就O(m+n)),列在回文中.
05/09 09:57, 3F

05/09 22:12, , 4F
如果是先給Y做hash呢?
05/09 22:12, 4F

05/09 22:13, , 5F
然後foreach X[i] , 找Yhash中有沒有想要的值...
05/09 22:13, 5F
文章代碼(AID): #1BvDg1_N (CSSE)
討論串 (同標題文章)
文章代碼(AID): #1BvDg1_N (CSSE)