マツシタのお勉強

HashSet

合計の入れ替え Cracking The Coding Interview

問題 2つの整数配列が与えられる。それぞれの配列から1つずつ要素を決め、それらを交換した時に2つの配列の要素の合計値が一致するようなペアを見つける問題。 入力: {4, 1, 2, 1, 1, 2} と {3, 6, 3, 3} 出力: {1, 3} 解法 全列挙の解法 O(A*B) i, jを添…

316. Remove Duplicate Letters : Past Google Coding Interview

Problem leetcode.com How to Solve This problem is solved by the following steps. find out index that each letter appears int the last position have the indexes calculating at step 1 in a array sort the arrays created at step2 4 check the s…